ZQuest Classic Coverage Report


Directory: src/
File: src/zc/zc_sys.cpp
Date: 2025-01-12 05:57:18
Exec Total Coverage
Lines: 1951 4490 43.5%
Functions: 136 332 41.0%
Branches: 1314 3740 35.1%

Line Branch Exec Source
1 #include "zc/zc_sys.h"
2
3 #include "allegro/gfx.h"
4 #include "allegro/gui.h"
5 #include "allegro5/joystick.h"
6 #include "base/files.h"
7 #include "base/render.h"
8 #include "zalleg/zalleg.h"
9 #include "base/qrs.h"
10 #include "base/dmap.h"
11 #include <functional>
12 #include <stdio.h>
13 #include <stdlib.h>
14 #include <cstring>
15 #include <math.h>
16 #include <map>
17 #include <filesystem>
18 #include <ctype.h>
19 #include <sstream>
20 #include "base/version.h"
21 #include "base/zc_alleg.h"
22 #include "gamedata.h"
23 #include "zc/replay_upload.h"
24 #include "zc/zc_init.h"
25 #include "init.h"
26 #include "zc/replay.h"
27 #include "zc/cheats.h"
28 #include "zc/render.h"
29 #include "base/zc_math.h"
30 #include "base/zapp.h"
31 #include "dialog/cheatkeys.h"
32 #include "metadata/metadata.h"
33 #include "zc/zelda.h"
34 #include "zc/saves.h"
35 #include "tiles.h"
36 #include "base/colors.h"
37 #include "pal.h"
38 #include "base/zsys.h"
39 #include "base/qst.h"
40 #include "zc/zc_sys.h"
41 #include "play_midi.h"
42 #include "gui/jwin_a5.h"
43 #include "base/jwinfsel.h"
44 #include "base/gui.h"
45 #include "midi.h"
46 #include "subscr.h"
47 #include "zc/maps.h"
48 #include "sprite.h"
49 #include "zc/guys.h"
50 #include "zc/hero.h"
51 #include "zc/title.h"
52 #include "particles.h"
53 #include "sound/zcmusic.h"
54 #include "zconsole.h"
55 #include "zc/ffscript.h"
56 #include "dialog/info.h"
57 #include "dialog/alert.h"
58 #include "zc/combos.h"
59 #include "zc/jit.h"
60 #include "zc/zc_subscr.h"
61 #include <fmt/format.h>
62 #include "zconsole/ConsoleLogger.h"
63 #include "zinfo.h"
64 #include "base/misctypes.h"
65 #include "music_playback.h"
66 #include <base/new_menu.h>
67 #include <base/files.h>
68
69 #ifdef __EMSCRIPTEN__
70 #include "base/emscripten_utils.h"
71 #endif
72
73 using namespace std::chrono_literals;
74
75 extern bool Playing;
76 int32_t sfx_voice[WAV_COUNT];
77 int32_t d_stringloader(int32_t msg,DIALOG *d,int32_t c);
78 int32_t d_midilist_proc(int32_t msg,DIALOG *d,int32_t c);
79
80 static ALLEGRO_JOYSTICK* gamepad_dlg_cur_joystick;
81 static int32_t d_joylist_proc(int32_t msg,DIALOG *d,int32_t c);
82
83 extern byte monochrome_console;
84
85 extern HeroClass Hero;
86 extern zcmodule moduledata;
87 extern sprite_list guys, items, Ewpns, Lwpns, chainlinks, decorations;
88 extern particle_list particles;
89 extern int32_t loadlast;
90 extern char *sfx_string[WAV_COUNT];
91 byte use_dwm_flush;
92 byte use_save_indicator;
93 int32_t paused_midi_pos = 0;
94 byte midi_suspended = 0;
95 byte zc_192b163_warp_compatibility;
96 char modulepath[2048];
97 bool epilepsyFlashReduction;
98 signed char pause_in_background_menu_init = 0;
99 byte pause_in_background = 0;
100 bool is_sys_pal = false;
101 static bool load_control_called_this_frame;
102 extern PALETTE* hw_palette;
103 extern bool update_hw_pal;
104 extern const char* dmaplist(int32_t index, int32_t* list_size);
105 int32_t getnumber(const char *prompt,int32_t initialval);
106
107 extern bool kb_typing_mode; //script only, for disbaling key presses affecting Hero, etc.
108 extern int32_t cheat_modifier_keys[4]; //two options each, default either control and either shift
109
110 static const char *qst_module_name = "current_module";
111 #ifdef ALLEGRO_LINUX
112 static const char *samplepath = "samplesoundset/patches.dat";
113 #endif
114 char qst_files_path[2048];
115
116 extern TopMenu the_player_menu;
117 #ifdef _MSC_VER
118 #define getcwd _getcwd
119 #endif
120
121 bool rF11();
122 bool rI();
123 bool rQ();
124 bool zc_key_pressed();
125
126 #ifdef _WIN32
127
128 // This should only be necessary for MinGW, since it doesn't have a dwmapi.h. Add another #ifdef if you like.
129 extern "C"
130 {
131 typedef HRESULT(WINAPI *t_DwmFlush)();
132 typedef HRESULT(WINAPI *t_DwmIsCompositionEnabled)(BOOL *pfEnabled);
133 }
134
135 void do_DwmFlush()
136 {
137 static HMODULE shell = LoadLibrary("dwmapi.dll");
138
139 if(!shell)
140 return;
141
142 static t_DwmFlush flush=reinterpret_cast<t_DwmFlush>(GetProcAddress(shell, "DwmFlush"));
143 static t_DwmIsCompositionEnabled isEnabled=reinterpret_cast<t_DwmIsCompositionEnabled>(GetProcAddress(shell, "DwmIsCompositionEnabled"));
144
145 BOOL enabled;
146 isEnabled(&enabled);
147
148 if(isEnabled)
149 flush();
150 }
151
152 #endif // _WIN32
153
154 246 void zc_exit(int code)
155 {
156 extern CConsoleLoggerEx zscript_coloured_console;
157
158 246 set_is_exiting();
159
160
1/2
✓ Branch 0 taken 246 times.
✗ Branch 1 not taken.
246 if (replay_get_mode() == ReplayMode::Record) replay_save();
161 246 replay_stop();
162 246 music_stop();
163 246 kill_sfx();
164
165
2/2
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 240 times.
246 if (get_qr(qr_OLD_SCRIPT_VOLUME))
166 {
167 //restore user volume settings
168
2/2
✓ Branch 0 taken 239 times.
✓ Branch 1 taken 1 times.
240 if (FFCore.coreflags & FFCORE_SCRIPTED_MIDI_VOLUME)
169 {
170 1 master_volume(-1, ((int32_t)FFCore.usr_midi_volume));
171 1 }
172
2/2
✓ Branch 0 taken 239 times.
✓ Branch 1 taken 1 times.
240 if (FFCore.coreflags & FFCORE_SCRIPTED_DIGI_VOLUME)
173 {
174 1 master_volume((int32_t)(FFCore.usr_digi_volume), 1);
175 1 }
176
2/2
✓ Branch 0 taken 239 times.
✓ Branch 1 taken 1 times.
240 if (FFCore.coreflags & FFCORE_SCRIPTED_MUSIC_VOLUME)
177 {
178 1 emusic_volume = (int32_t)FFCore.usr_music_volume;
179 1 }
180
1/2
✓ Branch 0 taken 240 times.
✗ Branch 1 not taken.
240 if (FFCore.coreflags & FFCORE_SCRIPTED_SFX_VOLUME)
181 {
182 sfx_volume = (int32_t)FFCore.usr_sfx_volume;
183 }
184 240 }
185
1/2
✓ Branch 0 taken 246 times.
✗ Branch 1 not taken.
246 if ( FFCore.coreflags&FFCORE_SCRIPTED_PANSTYLE )
186 {
187 pan_style = (int32_t)FFCore.usr_panstyle;
188 }
189 246 save_game_configs();
190
191 246 zscript_coloured_console.kill();
192 246 jit_shutdown();
193 246 quit_game();
194
195 246 Z_message("ZQuest Classic web site: https://zquestclassic.com\n");
196 246 Z_message("ZQuest Classic old wiki: https://web.archive.org/web/20210910193102/https://zeldaclassic.com/wiki\n");
197 246 Z_message("ZQuest Classic new wiki: https://github.com/ZQuestClassic/ZQuestClassic/wiki\n");
198
199 246 allegro_exit();
200 246 exit(code);
201 }
202
203 92829 bool flash_reduction_enabled(bool check_qr)
204 {
205
4/4
✓ Branch 0 taken 88404 times.
✓ Branch 1 taken 4425 times.
✓ Branch 2 taken 87576 times.
✓ Branch 3 taken 92001 times.
92829 return (check_qr && get_qr(qr_EPILEPSY)) || epilepsyFlashReduction || replay_is_debug();
206 }
207
208 // Dialogue largening
209 void large_dialog(DIALOG *d)
210 {
211 large_dialog(d, 1.5);
212 }
213
214 void large_dialog(DIALOG *d, float RESIZE_AMT)
215 {
216 if(!d[0].d1)
217 {
218 d[0].d1 = 1;
219 int32_t oldwidth = d[0].w;
220 int32_t oldheight = d[0].h;
221 int32_t oldx = d[0].x;
222 int32_t oldy = d[0].y;
223 d[0].x -= int32_t(d[0].w/RESIZE_AMT);
224 d[0].y -= int32_t(d[0].h/RESIZE_AMT);
225 d[0].w = int32_t(d[0].w*RESIZE_AMT);
226 d[0].h = int32_t(d[0].h*RESIZE_AMT);
227
228 for(int32_t i=1; d[i].proc !=NULL; i++)
229 {
230 // Place elements horizontally
231 double xpc = ((double)(d[i].x - oldx) / (double)oldwidth);
232 d[i].x = int32_t(d[0].x + (xpc*d[0].w));
233
234 if(d[i].proc != d_stringloader)
235 {
236 if(d[i].proc==d_bitmap_proc)
237 {
238 d[i].w *= 2;
239 }
240 else d[i].w = int32_t(d[i].w*RESIZE_AMT);
241 }
242
243 // Place elements vertically
244 double ypc = ((double)(d[i].y - oldy) / (double)oldheight);
245 d[i].y = int32_t(d[0].y + (ypc*d[0].h));
246
247 // Vertically resize elements
248 if(d[i].proc == jwin_edit_proc || d[i].proc == jwin_check_proc || d[i].proc == jwin_checkfont_proc)
249 {
250 d[i].h = int32_t((double)d[i].h*1.5);
251 }
252 else if(d[i].proc == jwin_droplist_proc || d[i].proc == d_joylist_proc)
253 {
254 d[i].y += int32_t((double)d[i].h*0.25);
255 d[i].h = int32_t((double)d[i].h*1.25);
256 }
257 else if(d[i].proc==d_bitmap_proc)
258 {
259 d[i].h *= 2;
260 }
261 else d[i].h = int32_t(d[i].h*RESIZE_AMT);
262
263 // Fix frames
264 if(d[i].proc == jwin_frame_proc)
265 {
266 d[i].x++;
267 d[i].y++;
268 d[i].w-=4;
269 d[i].h-=4;
270 }
271 }
272 }
273
274 for(int32_t i=1; d[i].proc!=NULL; i++)
275 {
276 if(d[i].proc==jwin_slider_proc)
277 continue;
278
279 // Bigger font
280 bool bigfontproc = (d[i].proc != d_midilist_proc && d[i].proc != jwin_droplist_proc && d[i].proc != jwin_abclist_proc && d[i].proc != jwin_list_proc && d[i].proc != d_joylist_proc);
281
282 if(!d[i].dp2 && bigfontproc)
283 {
284 d[i].dp2 = get_zc_font(font_lfont_l);
285 }
286 else if(!bigfontproc)
287 {
288 ((ListData *)d[i].dp)->font = &a4fonts[font_lfont_l];
289 }
290
291 // Make checkboxes work
292 if(d[i].proc == jwin_check_proc)
293 d[i].proc = jwin_checkfont_proc;
294 else if(d[i].proc == jwin_radio_proc)
295 d[i].proc = jwin_radiofont_proc;
296 }
297
298 jwin_center_dialog(d);
299 }
300
301 static char cfg_sect[] = "zeldadx"; //We need to rename this.
302 static char ctrl_sect[] = "Controls";
303 static char sfx_sect[] = "Volume";
304
305 int32_t d_dummy_proc(int32_t,DIALOG *,int32_t)
306 {
307 return D_O_K;
308 }
309
310 bool is_reserved_key(int c)
311 {
312 switch(c)
313 {
314 case KEY_ESC:
315 return true;
316 }
317 return false;
318 }
319 bool is_reserved_keycombo(int c, int modflag)
320 {
321 if(c==KEY_F4 && (modflag&KB_ALT_FLAG))
322 return true;
323 return false;
324 }
325 bool checkcheat(Cheat cheat)
326 {
327 if(cheatkeys[cheat][0] && zc_readkey(cheatkeys[cheat][0]))
328 return true; //Main key pressed
329 if(cheatkeys[cheat][1] && zc_readkey(cheatkeys[cheat][1]))
330 return true; //Alt key pressed
331 return false;
332 }
333 246 void load_default_cheatkeys()
334 {
335 246 memset(cheatkeys, 0, sizeof(cheatkeys));
336 246 cheatkeys[Cheat::Life][0] = KEY_H;
337 246 cheatkeys[Cheat::Life][1] = KEY_ASTERISK;
338 246 cheatkeys[Cheat::Magic][0] = KEY_M;
339 246 cheatkeys[Cheat::Magic][1] = KEY_SLASH_PAD;
340 246 cheatkeys[Cheat::Rupies][0] = KEY_R;
341 246 cheatkeys[Cheat::Bombs][0] = KEY_B;
342 246 cheatkeys[Cheat::Arrows][0] = KEY_A;
343 246 cheatkeys[Cheat::Clock][0] = KEY_I;
344 246 cheatkeys[Cheat::Walls][0] = KEY_F11;
345 246 cheatkeys[Cheat::Fast][0] = KEY_Q;
346 246 cheatkeys[Cheat::Light][0] = KEY_L;
347 246 cheatkeys[Cheat::IgnoreSideView][0] = KEY_V;
348 246 cheatkeys[Cheat::Kill][0] = KEY_K;
349 246 cheatkeys[Cheat::GoTo][0] = KEY_G;
350 246 cheatkeys[Cheat::TrigSecrets][0] = KEY_S;
351 246 cheatkeys[Cheat::ShowL0][0] = KEY_0;
352 246 cheatkeys[Cheat::ShowL1][0] = KEY_1;
353 246 cheatkeys[Cheat::ShowL2][0] = KEY_2;
354 246 cheatkeys[Cheat::ShowL3][0] = KEY_3;
355 246 cheatkeys[Cheat::ShowL4][0] = KEY_4;
356 246 cheatkeys[Cheat::ShowL5][0] = KEY_5;
357 246 cheatkeys[Cheat::ShowL6][0] = KEY_6;
358 246 cheatkeys[Cheat::ShowFFC][0] = KEY_7;
359 246 cheatkeys[Cheat::ShowSprites][0] = KEY_8;
360 246 cheatkeys[Cheat::ShowWalkability][0] = KEY_W;
361 246 cheatkeys[Cheat::ShowEffects][0] = KEY_E;
362 246 cheatkeys[Cheat::ShowOverhead][0] = KEY_O;
363 246 cheatkeys[Cheat::ShowPushblock][0] = KEY_P;
364 246 cheatkeys[Cheat::ShowHitbox][0] = KEY_C;
365 246 cheatkeys[Cheat::ShowFFCScripts][0] = KEY_F;
366 246 }
367
368 static bool loaded_game_configs;
369
370 246 void load_game_configs()
371 {
372 246 loaded_game_configs = true;
373 246 strcpy(moduledata.module_name,zc_get_config("ZCMODULE",qst_module_name,"modules/classic.zmod"));
374 246 joystick_index = zc_get_config(ctrl_sect,"joystick_index",0);
375 246 js_stick_1_x_stick = zc_get_config(ctrl_sect,"js_stick_1_x_stick",0);
376 246 js_stick_1_x_axis = zc_get_config(ctrl_sect,"js_stick_1_x_axis",0);
377 246 js_stick_1_x_offset = zc_get_config(ctrl_sect,"js_stick_1_x_offset",0) ? 128 : 0;
378 246 js_stick_1_y_stick = zc_get_config(ctrl_sect,"js_stick_1_y_stick",0);
379 246 js_stick_1_y_axis = zc_get_config(ctrl_sect,"js_stick_1_y_axis",1);
380 246 js_stick_1_y_offset = zc_get_config(ctrl_sect,"js_stick_1_y_offset",0) ? 128 : 0;
381 246 js_stick_2_x_stick = zc_get_config(ctrl_sect,"js_stick_2_x_stick",1);
382 246 js_stick_2_x_axis = zc_get_config(ctrl_sect,"js_stick_2_x_axis",0);
383 246 js_stick_2_x_offset = zc_get_config(ctrl_sect,"js_stick_2_x_offset",0) ? 128 : 0;
384 246 js_stick_2_y_stick = zc_get_config(ctrl_sect,"js_stick_2_y_stick",1);
385 246 js_stick_2_y_axis = zc_get_config(ctrl_sect,"js_stick_2_y_axis",1);
386 246 js_stick_2_y_offset = zc_get_config(ctrl_sect,"js_stick_2_y_offset",0) ? 128 : 0;
387 246 analog_movement = (zc_get_config(ctrl_sect,"analog_movement",1));
388
389 //cheat modifier keya
390 246 cheat_modifier_keys[0] = zc_get_config(ctrl_sect,"key_cheatmod_a1",KEY_ZC_LCONTROL);
391 246 cheat_modifier_keys[1] = zc_get_config(ctrl_sect,"key_cheatmod_a2",0);
392 246 cheat_modifier_keys[2] = zc_get_config(ctrl_sect,"key_cheatmod_b1",KEY_ZC_RCONTROL);
393 246 cheat_modifier_keys[3] = zc_get_config(ctrl_sect,"key_cheatmod_b2",0);
394
395 //cheat keys
396 246 load_default_cheatkeys();
397 char buf[256];
398
2/2
✓ Branch 0 taken 246 times.
✓ Branch 1 taken 8856 times.
9102 for(size_t q = 1; q < Cheat::Last; ++q)
399 {
400
1/2
✓ Branch 0 taken 8856 times.
✗ Branch 1 not taken.
8856 if(!bindable_cheat((Cheat)q)) continue;
401 8856 std::string cheatname = cheat_to_string((Cheat)q);
402
1/2
✓ Branch 0 taken 8856 times.
✗ Branch 1 not taken.
8856 util::lowerstr(cheatname);
403 8856 sprintf(buf, "key_cheat_%s_main", cheatname.c_str());
404
1/2
✓ Branch 0 taken 8856 times.
✗ Branch 1 not taken.
8856 cheatkeys[q][0] = zc_get_config(ctrl_sect,buf,cheatkeys[q][0]);
405 8856 sprintf(buf, "key_cheat_%s_alt", cheatname.c_str());
406
1/2
✓ Branch 0 taken 8856 times.
✗ Branch 1 not taken.
8856 cheatkeys[q][1] = zc_get_config(ctrl_sect,buf,cheatkeys[q][1]);
407 8856 }
408
409
1/2
✓ Branch 0 taken 246 times.
✗ Branch 1 not taken.
246 if((uint32_t)joystick_index >= MAX_JOYSTICKS)
410 joystick_index = 0;
411
412 246 Akey = zc_get_config(ctrl_sect,"key_a",KEY_Z);
413 246 Bkey = zc_get_config(ctrl_sect,"key_b",KEY_X);
414 246 Skey = zc_get_config(ctrl_sect,"key_s",KEY_ENTER);
415 246 Lkey = zc_get_config(ctrl_sect,"key_l",KEY_Q);
416 246 Rkey = zc_get_config(ctrl_sect,"key_r",KEY_W);
417 246 Pkey = zc_get_config(ctrl_sect,"key_p",KEY_SPACE);
418 246 Exkey1 = zc_get_config(ctrl_sect,"key_ex1",KEY_A);
419 246 Exkey2 = zc_get_config(ctrl_sect,"key_ex2",KEY_S);
420 246 Exkey3 = zc_get_config(ctrl_sect,"key_ex3",KEY_D);
421 246 Exkey4 = zc_get_config(ctrl_sect,"key_ex4",KEY_C);
422
423 246 DUkey = zc_get_config(ctrl_sect,"key_up", KEY_UP);
424 246 DDkey = zc_get_config(ctrl_sect,"key_down", KEY_DOWN);
425 246 DLkey = zc_get_config(ctrl_sect,"key_left", KEY_LEFT);
426 246 DRkey = zc_get_config(ctrl_sect,"key_right",KEY_RIGHT);
427
428 246 Abtn = zc_get_config(ctrl_sect,"btn_a",2);
429 246 Bbtn = zc_get_config(ctrl_sect,"btn_b",1);
430 246 Sbtn = zc_get_config(ctrl_sect,"btn_s",10);
431 246 Mbtn = zc_get_config(ctrl_sect,"btn_m",9);
432 246 Lbtn = zc_get_config(ctrl_sect,"btn_l",5);
433 246 Rbtn = zc_get_config(ctrl_sect,"btn_r",6);
434 246 Pbtn = zc_get_config(ctrl_sect,"btn_p",12);
435 246 Exbtn1 = zc_get_config(ctrl_sect,"btn_ex1",7);
436 246 Exbtn2 = zc_get_config(ctrl_sect,"btn_ex2",8);
437 246 Exbtn3 = zc_get_config(ctrl_sect,"btn_ex3",4);
438 246 Exbtn4 = zc_get_config(ctrl_sect,"btn_ex4",3);
439
440 246 DUbtn = zc_get_config(ctrl_sect,"btn_up",13);
441 246 DDbtn = zc_get_config(ctrl_sect,"btn_down",14);
442 246 DLbtn = zc_get_config(ctrl_sect,"btn_left",15);
443 246 DRbtn = zc_get_config(ctrl_sect,"btn_right",16);
444
445 246 epilepsyFlashReduction = zc_get_config(cfg_sect,"epilepsy_flash_reduction",0);
446
447 246 midi_volume = zc_get_config(sfx_sect,"midi",255);
448 246 sfx_volume = zc_get_config(sfx_sect,"sfx",255);
449 246 emusic_volume = zc_get_config(sfx_sect,"emusic",255);
450 246 pan_style = zc_get_config(sfx_sect,"pan",1);
451 246 volkeys = zc_get_config(sfx_sect,"volkeys",0)!=0;
452 246 zc_vsync = zc_get_config(cfg_sect,"vsync",0);
453 246 Throttlefps = zc_get_config(cfg_sect,"throttlefps",1)!=0;
454 246 Maxfps = zc_get_config(cfg_sect,"maxfps",0);
455 246 TransLayers = zc_get_config(cfg_sect,"translayers",1)!=0;
456 246 SnapshotFormat = zc_get_config(cfg_sect,"snapshot_format",3);
457 246 SnapshotScale = zc_get_config(cfg_sect,"snapshot_scale",2);
458 246 NameEntryMode = zc_get_config(cfg_sect,"name_entry_mode",0);
459 #ifdef __EMSCRIPTEN__
460 if (em_is_mobile()) NameEntryMode = 2;
461 #endif
462 246 ShowFPS = zc_get_config(cfg_sect,"showfps",0)!=0;
463 246 ShowGameTime = zc_get_config(cfg_sect,"showtime",0);
464 246 NESquit = zc_get_config(cfg_sect,"fastquit",0)!=0;
465 246 ClickToFreeze = zc_get_config(cfg_sect,"clicktofreeze",1)!=0;
466 246 abc_patternmatch = zc_get_config(cfg_sect, "lister_pattern_matching", 1);
467 246 pause_in_background = zc_get_config(cfg_sect, "pause_in_background", 0);
468
469 246 window_width = resx = zc_get_config(cfg_sect,"window_width",-1);
470 246 window_height = resy = zc_get_config(cfg_sect,"window_height",-1);
471 246 SaveDragResize = zc_get_config(cfg_sect,"save_drag_resize",0)!=0;
472 246 DragAspect = zc_get_config(cfg_sect,"drag_aspect",0)!=0;
473 246 SaveWinPos = zc_get_config(cfg_sect,"save_window_position",0)!=0;
474 246 scaleForceInteger = zc_get_config("zeldadx","scaling_force_integer",1)!=0;
475 246 stretchGame = zc_get_config("zeldadx","stretch_game_area",0)!=0;
476
477 246 loadlast = zc_get_config(cfg_sect,"load_last",0);
478
479 246 fullscreen = zc_get_config(cfg_sect,"fullscreen",0);
480
481 246 info_opacity = zc_get_config("zc","debug_info_opacity",255);
482 #ifdef _WIN32
483 console_enabled = (byte) zc_get_config("CONSOLE", "enabled", 0);
484 //use_win7_keyboard_fix = (byte) zc_get_config(cfg_sect,"use_win7_key_fix",0);
485 use_win32_proc = (byte) zc_get_config(cfg_sect,"zc_win_proc_fix",0); //buggy
486
487 // This one's for Aero
488 use_dwm_flush = (byte) zc_get_config("zeldadx","use_dwm_flush",0);
489
490 monochrome_console = (byte) zc_get_config("CONSOLE","monochrome_debuggers",0);
491 #else //UNIX
492 246 console_enabled = (byte) zc_get_config("CONSOLE", "enabled", 0);
493 246 monochrome_console = (byte) zc_get_config("CONSOLE","monochrome_debuggers",0);
494 #endif
495 246 clearConsoleOnLoad = zc_get_config("CONSOLE","clear_console_on_load",1)!=0;
496 246 clearConsoleOnReload = zc_get_config("CONSOLE","clear_console_on_reload",0)!=0;
497
498 246 strcpy(qstdir,zc_get_config(cfg_sect,"quest_dir","quests"));
499 246 strcpy(qstpath,qstdir); //qstpath is the local (for this run of ZC) quest path, qstdir is the universal quest dir.
500 246 ss_enable = zc_get_config(cfg_sect,"ss_enable",1) ? 1 : 0;
501 246 ss_after = vbound(zc_get_config(cfg_sect,"ss_after",14), 0, 14);
502 246 ss_speed = vbound(zc_get_config(cfg_sect,"ss_speed",2), 0, 6);
503 246 ss_density = vbound(zc_get_config(cfg_sect,"ss_density",3), 0, 6);
504 246 heart_beep = zc_get_config(cfg_sect,"heart_beep",0)!=0;
505 //gui_colorset = zc_get_config(cfg_sect,"gui_colorset",0);
506 246 sfxdat = zc_get_config(cfg_sect,"use_sfx_dat",1); // TODO: sfxdat is always set to 1 for titlescreen... and 0 in readsfx... so this cfg is pointless, remove?
507 246 fullscreen = zc_get_config(cfg_sect,"fullscreen",0);
508 246 use_save_indicator = zc_get_config(cfg_sect,"save_indicator",0);
509 246 zc_192b163_warp_compatibility = zc_get_config(cfg_sect,"zc_192b163_warp_compatibility",0);
510 246 SkipTitle = zc_get_config(cfg_sect,"skip_title",0);
511 246 }
512
513 void save_control_configs(bool kb)
514 {
515 if(kb)
516 {
517 zc_set_config(ctrl_sect,"key_cheatmod_a1",cheat_modifier_keys[0]);
518 zc_set_config(ctrl_sect,"key_cheatmod_a2",cheat_modifier_keys[1]);
519 zc_set_config(ctrl_sect,"key_cheatmod_b1",cheat_modifier_keys[2]);
520 zc_set_config(ctrl_sect,"key_cheatmod_b2",cheat_modifier_keys[3]);
521
522 if (!replay_is_replaying())
523 {
524 zc_set_config(ctrl_sect,"key_a",Akey);
525 zc_set_config(ctrl_sect,"key_b",Bkey);
526 zc_set_config(ctrl_sect,"key_s",Skey);
527 zc_set_config(ctrl_sect,"key_l",Lkey);
528 zc_set_config(ctrl_sect,"key_r",Rkey);
529 zc_set_config(ctrl_sect,"key_p",Pkey);
530 zc_set_config(ctrl_sect,"key_ex1",Exkey1);
531 zc_set_config(ctrl_sect,"key_ex2",Exkey2);
532 zc_set_config(ctrl_sect,"key_ex3",Exkey3);
533 zc_set_config(ctrl_sect,"key_ex4",Exkey4);
534 zc_set_config(ctrl_sect,"key_up", DUkey);
535 zc_set_config(ctrl_sect,"key_down", DDkey);
536 zc_set_config(ctrl_sect,"key_left", DLkey);
537 zc_set_config(ctrl_sect,"key_right",DRkey);
538 }
539 }
540 else
541 {
542 zc_set_config(ctrl_sect,"joystick_index",joystick_index);
543 zc_set_config(ctrl_sect,"js_stick_1_x_stick",js_stick_1_x_stick);
544 zc_set_config(ctrl_sect,"js_stick_1_x_axis",js_stick_1_x_axis);
545 zc_set_config(ctrl_sect,"js_stick_1_x_offset",js_stick_1_x_offset ? 1 : 0);
546 zc_set_config(ctrl_sect,"js_stick_1_y_stick",js_stick_1_y_stick);
547 zc_set_config(ctrl_sect,"js_stick_1_y_axis",js_stick_1_y_axis);
548 zc_set_config(ctrl_sect,"js_stick_1_y_offset",js_stick_1_y_offset ? 1 : 0);
549 zc_set_config(ctrl_sect,"js_stick_2_x_stick",js_stick_2_x_stick);
550 zc_set_config(ctrl_sect,"js_stick_2_x_axis",js_stick_2_x_axis);
551 zc_set_config(ctrl_sect,"js_stick_2_x_offset",js_stick_2_x_offset ? 1 : 0);
552 zc_set_config(ctrl_sect,"js_stick_2_y_stick",js_stick_2_y_stick);
553 zc_set_config(ctrl_sect,"js_stick_2_y_axis",js_stick_2_y_axis);
554 zc_set_config(ctrl_sect,"js_stick_2_y_offset",js_stick_2_y_offset ? 1 : 0);
555 zc_set_config(ctrl_sect,"analog_movement",analog_movement);
556
557 zc_set_config(ctrl_sect,"btn_a",Abtn);
558 zc_set_config(ctrl_sect,"btn_b",Bbtn);
559 zc_set_config(ctrl_sect,"btn_s",Sbtn);
560 zc_set_config(ctrl_sect,"btn_m",Mbtn);
561 zc_set_config(ctrl_sect,"btn_l",Lbtn);
562 zc_set_config(ctrl_sect,"btn_r",Rbtn);
563 zc_set_config(ctrl_sect,"btn_p",Pbtn);
564 zc_set_config(ctrl_sect,"btn_ex1",Exbtn1);
565 zc_set_config(ctrl_sect,"btn_ex2",Exbtn2);
566 zc_set_config(ctrl_sect,"btn_ex3",Exbtn3);
567 zc_set_config(ctrl_sect,"btn_ex4",Exbtn4);
568
569 zc_set_config(ctrl_sect,"btn_up",DUbtn);
570 zc_set_config(ctrl_sect,"btn_down",DDbtn);
571 zc_set_config(ctrl_sect,"btn_left",DLbtn);
572 zc_set_config(ctrl_sect,"btn_right",DRbtn);
573 }
574 }
575
576 void save_cheatkeys()
577 {
578 char buf[256];
579 for(size_t q = 1; q < Cheat::Last; ++q)
580 {
581 if(!bindable_cheat((Cheat)q)) continue;
582 std::string cheatname = cheat_to_string((Cheat)q);
583 util::lowerstr(cheatname);
584 sprintf(buf, "key_cheat_%s_main", cheatname.c_str());
585 zc_set_config(ctrl_sect,buf,cheatkeys[q][0]);
586 sprintf(buf, "key_cheat_%s_alt", cheatname.c_str());
587 if(cheatkeys[q][1])
588 zc_set_config(ctrl_sect,buf,cheatkeys[q][1]);
589 else zc_set_config(ctrl_sect,buf,(char*)nullptr);
590 }
591 }
592
593 246 void save_game_configs()
594 {
595
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 246 times.
246 if (!loaded_game_configs) return;
596
597 246 packfile_password("");
598
599 246 zc_set_config("ZCMODULE",qst_module_name,moduledata.module_name);
600
601
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 246 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
246 if (all_get_display() && !all_get_fullscreen_flag()&& SaveWinPos)
602 {
603 int o_window_x, o_window_y;
604 al_get_window_position(all_get_display(), &o_window_x, &o_window_y);
605 zc_set_config(cfg_sect,"window_x",o_window_x);
606 zc_set_config(cfg_sect,"window_y",o_window_y);
607 }
608
609
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 246 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
246 if (all_get_display() && !all_get_fullscreen_flag() && SaveDragResize)
610 {
611 window_width = al_get_display_width(all_get_display());
612 window_height = al_get_display_height(all_get_display());
613 zc_set_config(cfg_sect,"window_width",window_width);
614 zc_set_config(cfg_sect,"window_height",window_height);
615 }
616
617 246 zc_set_config(cfg_sect,"load_last",loadlast);
618 246 zc_set_config(cfg_sect,"use_sfx_dat",sfxdat);
619
620 246 flush_config_file();
621 #ifdef __EMSCRIPTEN__
622 em_sync_fs();
623 #endif
624 246 }
625
626 //----------------------------------------------------------------
627
628 // Timers
629
630 43188 void fps_callback()
631 {
632 43188 lastfps=framecnt;
633 43188 framecnt=0;
634 43188 }
635
636 END_OF_FUNCTION(fps_callback)
637
638 246 int32_t Z_init_timers()
639 {
640 static bool didit = false;
641 const static char *err_str = "Couldn't allocate timer";
642 246 err_str = err_str; //Unused variable warning
643
644
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 246 times.
246 if(didit)
645 return 1;
646
647 246 didit = true;
648
649 LOCK_VARIABLE(lastfps);
650 LOCK_VARIABLE(framecnt);
651 LOCK_FUNCTION(fps_callback);
652
653
1/2
✓ Branch 0 taken 246 times.
✗ Branch 1 not taken.
246 if(install_int_ex(fps_callback,SECS_TO_TIMER(1)))
654 return 0;
655
656 246 return 1;
657 246 }
658
659 246 void Z_remove_timers()
660 {
661 246 remove_int(fps_callback);
662 246 }
663
664 //----------------------------------------------------------------
665
666 void go()
667 {
668 blit(screen,tmp_scr,scrx,scry,0,0,screen->w,screen->h);
669 }
670
671 void comeback()
672 {
673 blit(tmp_scr,screen,0,0,scrx,scry,screen->w,screen->h);
674 }
675
676 void dump_pal(BITMAP *dest)
677 {
678 for(int32_t i=0; i<256; i++)
679 rectfill(dest,(i&63)<<2,(i&0xFC0)>>4,((i&63)<<2)+3,((i&0xFC0)>>4)+3,i);
680 }
681
682 //----------------------------------------------------------------
683
684 int game_mouse_index = ZCM_BLANK;
685 static bool system_mouse = false;
686 110 bool sys_mouse()
687 {
688 110 system_mouse = true;
689 110 return MouseSprite::set(ZCM_NORMAL);
690 }
691 1481 bool game_mouse()
692 {
693 1481 system_mouse = false;
694 1481 return MouseSprite::set(game_mouse_index);
695 }
696 void custom_mouse(BITMAP* bmp, int fx, int fy, bool sys_recolor, bool user_scale)
697 {
698 if(!bmp)
699 return;
700 float scale = vbound(zc_get_config("zeldadx","cursor_scale_large",1.5),1.0,5.0);
701 int scaledw = bmp->w*scale, scaledh = bmp->h*scale;
702 if(bmp->w == scaledw && bmp->h == scaledh)
703 user_scale = false;
704 if(user_scale || sys_recolor)
705 {
706 if(!user_scale) scale = 1;
707 BITMAP* tmpbmp = create_bitmap_ex(8,bmp->w*scale,bmp->h*scale);
708 if(user_scale)
709 stretch_blit(bmp, tmpbmp, 0, 0, bmp->w, bmp->h, 0, 0, tmpbmp->w, tmpbmp->h);
710 else
711 blit(bmp, tmpbmp, 0, 0, 0, 0, bmp->w, bmp->h);
712 if(sys_recolor)
713 recolor_mouse(tmpbmp);
714 MouseSprite::assign(ZCM_CUSTOM, tmpbmp, fx*scale, fy*scale);
715 destroy_bitmap(tmpbmp);
716 }
717 else
718 {
719 MouseSprite::assign(ZCM_CUSTOM, bmp, fx, fy);
720 }
721 }
722
723 //Handles converting the mouse sprite from the .dat file
724 void recolor_mouse(BITMAP* bmp)
725 {
726 for(int32_t x = 0; x < bmp->w; ++x)
727 {
728 for(int32_t y = 0; y < bmp->h; ++y)
729 {
730 int32_t color = getpixel(bmp, x, y);
731 switch(color)
732 {
733 case dvc(1):
734 color = jwin_pal[jcCURSORMISC];
735 break;
736 case dvc(2):
737 color = jwin_pal[jcCURSOROUTLINE];
738 break;
739 case dvc(3):
740 color = jwin_pal[jcCURSORLIGHT];
741 break;
742 case dvc(5):
743 color = jwin_pal[jcCURSORDARK];
744 break;
745 default:
746 continue;
747 }
748 putpixel(bmp, x, y, color);
749 }
750 }
751 }
752 void load_mouse()
753 {
754 PALETTE pal;
755 BITMAP* cursor_bitmap = load_bitmap("assets/cursor.bmp", pal);
756 if (!cursor_bitmap)
757 Z_error_fatal("Missing required file %s\n", "assets/cursor.bmp");
758
759 enter_sys_pal();
760 MouseSprite::set(-1);
761 float scale = vbound(zc_get_config("zeldadx","cursor_scale_large",1.5),1.0,5.0);
762 int32_t sz = 16*scale;
763 for(int32_t j = 0; j < 1; ++j)
764 {
765 BITMAP* tmpbmp = create_bitmap_ex(8,16,16);
766 if(zcmouse[j])
767 destroy_bitmap(zcmouse[j]);
768 zcmouse[j] = create_bitmap_ex(8,sz,sz);
769 clear_bitmap(zcmouse[j]);
770 clear_bitmap(tmpbmp);
771 blit(cursor_bitmap,tmpbmp,1,j*17+1,0,0,16,16);
772 recolor_mouse(tmpbmp);
773 if(sz!=16)
774 stretch_blit(tmpbmp, zcmouse[j], 0, 0, 16, 16, 0, 0, sz, sz);
775 else
776 blit(tmpbmp, zcmouse[j], 0, 0, 0, 0, 16, 16);
777 destroy_bitmap(tmpbmp);
778 }
779 if(!hw_palette) hw_palette = &RAMpal;
780 zc_set_palette(*hw_palette);
781
782 BITMAP* blankmouse = create_bitmap_ex(8,16,16);
783 clear_bitmap(blankmouse);
784
785 MouseSprite::assign(ZCM_NORMAL, zcmouse[0], 1*scale, 1*scale);
786 MouseSprite::assign(ZCM_BLANK, blankmouse);
787 //Don't assign ZCM_CUSTOM. That'll be handled by scripts.
788
789 //Reload the mouse
790 if(system_mouse)
791 sys_mouse();
792 else game_mouse();
793
794 destroy_bitmap(blankmouse);
795 destroy_bitmap(cursor_bitmap);
796 exit_sys_pal();
797 }
798
799 // sets the video mode and initializes the palette and mouse sprite
800 246 bool game_vid_mode(int32_t mode,int32_t wait)
801 {
802
1/2
✓ Branch 0 taken 246 times.
✗ Branch 1 not taken.
246 if (is_headless())
803 246 return true;
804
805 extern int zq_screen_w, zq_screen_h;
806 if(set_gfx_mode(mode,resx,resy,zq_screen_w,zq_screen_h)!=0)
807 {
808 return false;
809 }
810
811 scrx = (resx-320)>>1;
812 scry = (resy-240)>>1;
813 for(int32_t q = 0; q < NUM_ZCMOUSE; ++q)
814 zcmouse[q] = NULL;
815 load_mouse();
816
817 for(int32_t i=240; i<256; i++)
818 RAMpal[i]=pal_gui[i];
819
820 zc_set_palette(RAMpal);
821 clear_to_color(screen,BLACK);
822
823 rest(wait);
824 return true;
825 246 }
826
827 254 void null_quest()
828 {
829
1/2
✓ Branch 0 taken 254 times.
✗ Branch 1 not taken.
254 std::string title_assets_path = "modules/classic/title_gfx.dat";
830
2/4
✓ Branch 0 taken 254 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 254 times.
254 if (get_last_loaded_qstpath() == title_assets_path)
831 return;
832
833 byte skip_flags[4];
834
2/2
✓ Branch 0 taken 254 times.
✓ Branch 1 taken 6604 times.
6858 for (int i = 0; i < skip_max; i++)
835
1/2
✓ Branch 0 taken 6604 times.
✗ Branch 1 not taken.
6604 set_bit(skip_flags, i, 1);
836
1/2
✓ Branch 0 taken 254 times.
✗ Branch 1 not taken.
254 set_bit(skip_flags, skip_tiles, 0);
837
1/2
✓ Branch 0 taken 254 times.
✗ Branch 1 not taken.
254 set_bit(skip_flags, skip_csets, 0);
838
1/2
✓ Branch 0 taken 254 times.
✗ Branch 1 not taken.
254 set_bit(skip_flags, skip_misc, 0); // needed for miscsfx (skip this and `tests/replays/demons_inferno/demons_inferno_1_of_2.zplay` fails).
839
1/2
✓ Branch 0 taken 254 times.
✗ Branch 1 not taken.
254 loadquest(title_assets_path.c_str(), &QHeader, &QMisc, tunes+ZC_MIDI_COUNT, false, skip_flags, 0, false);
840 254 sfxdat = 1;
841 // TODO: sfx.dat is ~1.2 MB. Could be better to break that up into individual files and load on demand / not at startup.
842 // TODO: can we cache the tiles/colordata so we don't have to read title_gfx.dat more than once?
843 // colordata is tiny, but tilebuf is huge, so limit that to just what the title screen needs.
844 // Another option: embed this data into the binary (`xxd -i resources/modules/classic/title_gfx.dat > title_gfx.h`)
845
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 254 times.
254 }
846
847 254 void init_NES_mode()
848 {
849 254 null_quest();
850 254 }
851
852 //----------------------------------------------------------------
853
854 qword trianglelines[16]=
855 {
856 0x0000000000000000ULL,
857 0xFD00000000000000ULL,
858 0xFDFD000000000000ULL,
859 0xFDFDFD0000000000ULL,
860 0xFDFDFDFD00000000ULL,
861 0xFDFDFDFDFD000000ULL,
862 0xFDFDFDFDFDFD0000ULL,
863 0xFDFDFDFDFDFDFD00ULL,
864 0xFDFDFDFDFDFDFDFDULL,
865 0x00FDFDFDFDFDFDFDULL,
866 0x0000FDFDFDFDFDFDULL,
867 0x000000FDFDFDFDFDULL,
868 0x00000000FDFDFDFDULL,
869 0x0000000000FDFDFDULL,
870 0x000000000000FDFDULL,
871 0x00000000000000FDULL,
872 };
873
874 word screen_triangles[28][32];
875
876 // the ULL suffixes are to prevent this warning:
877 // warning: integer constant is too large for "int32_t" type
878
879 qword triangles[4][16][8]= //[direction][value][line]
880 {
881 {
882 {
883 0x0000000000000000ULL,
884 0x0000000000000000ULL,
885 0x0000000000000000ULL,
886 0x0000000000000000ULL,
887 0x0000000000000000ULL,
888 0x0000000000000000ULL,
889 0x0000000000000000ULL,
890 0x0000000000000000ULL
891 },
892 {
893 0xFD00000000000000ULL,
894 0x0000000000000000ULL,
895 0x0000000000000000ULL,
896 0x0000000000000000ULL,
897 0x0000000000000000ULL,
898 0x0000000000000000ULL,
899 0x0000000000000000ULL,
900 0x0000000000000000ULL
901 },
902 {
903 0xFDFD000000000000ULL,
904 0xFD00000000000000ULL,
905 0x0000000000000000ULL,
906 0x0000000000000000ULL,
907 0x0000000000000000ULL,
908 0x0000000000000000ULL,
909 0x0000000000000000ULL,
910 0x0000000000000000ULL
911 },
912 {
913 0xFDFDFD0000000000ULL,
914 0xFDFD000000000000ULL,
915 0xFD00000000000000ULL,
916 0x0000000000000000ULL,
917 0x0000000000000000ULL,
918 0x0000000000000000ULL,
919 0x0000000000000000ULL,
920 0x0000000000000000ULL
921 },
922 {
923 0xFDFDFDFD00000000ULL,
924 0xFDFDFD0000000000ULL,
925 0xFDFD000000000000ULL,
926 0xFD00000000000000ULL,
927 0x0000000000000000ULL,
928 0x0000000000000000ULL,
929 0x0000000000000000ULL,
930 0x0000000000000000ULL
931 },
932 {
933 0xFDFDFDFDFD000000ULL,
934 0xFDFDFDFD00000000ULL,
935 0xFDFDFD0000000000ULL,
936 0xFDFD000000000000ULL,
937 0xFD00000000000000ULL,
938 0x0000000000000000ULL,
939 0x0000000000000000ULL,
940 0x0000000000000000ULL
941 },
942 {
943 0xFDFDFDFDFDFD0000ULL,
944 0xFDFDFDFDFD000000ULL,
945 0xFDFDFDFD00000000ULL,
946 0xFDFDFD0000000000ULL,
947 0xFDFD000000000000ULL,
948 0xFD00000000000000ULL,
949 0x0000000000000000ULL,
950 0x0000000000000000ULL
951 },
952 {
953 0xFDFDFDFDFDFDFD00ULL,
954 0xFDFDFDFDFDFD0000ULL,
955 0xFDFDFDFDFD000000ULL,
956 0xFDFDFDFD00000000ULL,
957 0xFDFDFD0000000000ULL,
958 0xFDFD000000000000ULL,
959 0xFD00000000000000ULL,
960 0x0000000000000000ULL
961 },
962 {
963 0xFDFDFDFDFDFDFDFDULL,
964 0xFDFDFDFDFDFDFD00ULL,
965 0xFDFDFDFDFDFD0000ULL,
966 0xFDFDFDFDFD000000ULL,
967 0xFDFDFDFD00000000ULL,
968 0xFDFDFD0000000000ULL,
969 0xFDFD000000000000ULL,
970 0xFD00000000000000ULL
971 },
972 {
973 0xFDFDFDFDFDFDFDFDULL,
974 0xFDFDFDFDFDFDFDFDULL,
975 0xFDFDFDFDFDFDFD00ULL,
976 0xFDFDFDFDFDFD0000ULL,
977 0xFDFDFDFDFD000000ULL,
978 0xFDFDFDFD00000000ULL,
979 0xFDFDFD0000000000ULL,
980 0xFDFD000000000000ULL
981 },
982 {
983 0xFDFDFDFDFDFDFDFDULL,
984 0xFDFDFDFDFDFDFDFDULL,
985 0xFDFDFDFDFDFDFDFDULL,
986 0xFDFDFDFDFDFDFD00ULL,
987 0xFDFDFDFDFDFD0000ULL,
988 0xFDFDFDFDFD000000ULL,
989 0xFDFDFDFD00000000ULL,
990 0xFDFDFD0000000000ULL
991 },
992 {
993 0xFDFDFDFDFDFDFDFDULL,
994 0xFDFDFDFDFDFDFDFDULL,
995 0xFDFDFDFDFDFDFDFDULL,
996 0xFDFDFDFDFDFDFDFDULL,
997 0xFDFDFDFDFDFDFD00ULL,
998 0xFDFDFDFDFDFD0000ULL,
999 0xFDFDFDFDFD000000ULL,
1000 0xFDFDFDFD00000000ULL
1001 },
1002 {
1003 0xFDFDFDFDFDFDFDFDULL,
1004 0xFDFDFDFDFDFDFDFDULL,
1005 0xFDFDFDFDFDFDFDFDULL,
1006 0xFDFDFDFDFDFDFDFDULL,
1007 0xFDFDFDFDFDFDFDFDULL,
1008 0xFDFDFDFDFDFDFD00ULL,
1009 0xFDFDFDFDFDFD0000ULL,
1010 0xFDFDFDFDFD000000ULL
1011 },
1012 {
1013 0xFDFDFDFDFDFDFDFDULL,
1014 0xFDFDFDFDFDFDFDFDULL,
1015 0xFDFDFDFDFDFDFDFDULL,
1016 0xFDFDFDFDFDFDFDFDULL,
1017 0xFDFDFDFDFDFDFDFDULL,
1018 0xFDFDFDFDFDFDFDFDULL,
1019 0xFDFDFDFDFDFDFD00ULL,
1020 0xFDFDFDFDFDFD0000ULL
1021 },
1022 {
1023 0xFDFDFDFDFDFDFDFDULL,
1024 0xFDFDFDFDFDFDFDFDULL,
1025 0xFDFDFDFDFDFDFDFDULL,
1026 0xFDFDFDFDFDFDFDFDULL,
1027 0xFDFDFDFDFDFDFDFDULL,
1028 0xFDFDFDFDFDFDFDFDULL,
1029 0xFDFDFDFDFDFDFDFDULL,
1030 0xFDFDFDFDFDFDFD00ULL
1031 },
1032 {
1033 0xFDFDFDFDFDFDFDFDULL,
1034 0xFDFDFDFDFDFDFDFDULL,
1035 0xFDFDFDFDFDFDFDFDULL,
1036 0xFDFDFDFDFDFDFDFDULL,
1037 0xFDFDFDFDFDFDFDFDULL,
1038 0xFDFDFDFDFDFDFDFDULL,
1039 0xFDFDFDFDFDFDFDFDULL,
1040 0xFDFDFDFDFDFDFDFDULL
1041 }
1042 },
1043 {
1044 {
1045 0x0000000000000000ULL,
1046 0x0000000000000000ULL,
1047 0x0000000000000000ULL,
1048 0x0000000000000000ULL,
1049 0x0000000000000000ULL,
1050 0x0000000000000000ULL,
1051 0x0000000000000000ULL,
1052 0x0000000000000000ULL
1053 },
1054 {
1055 0x00000000000000FDULL,
1056 0x0000000000000000ULL,
1057 0x0000000000000000ULL,
1058 0x0000000000000000ULL,
1059 0x0000000000000000ULL,
1060 0x0000000000000000ULL,
1061 0x0000000000000000ULL,
1062 0x0000000000000000ULL
1063 },
1064 {
1065 0x000000000000FDFDULL,
1066 0x00000000000000FDULL,
1067 0x0000000000000000ULL,
1068 0x0000000000000000ULL,
1069 0x0000000000000000ULL,
1070 0x0000000000000000ULL,
1071 0x0000000000000000ULL,
1072 0x0000000000000000ULL
1073 },
1074 {
1075 0x0000000000FDFDFDULL,
1076 0x000000000000FDFDULL,
1077 0x00000000000000FDULL,
1078 0x0000000000000000ULL,
1079 0x0000000000000000ULL,
1080 0x0000000000000000ULL,
1081 0x0000000000000000ULL,
1082 0x0000000000000000ULL
1083 },
1084 {
1085 0x00000000FDFDFDFDULL,
1086 0x0000000000FDFDFDULL,
1087 0x000000000000FDFDULL,
1088 0x00000000000000FDULL,
1089 0x0000000000000000ULL,
1090 0x0000000000000000ULL,
1091 0x0000000000000000ULL,
1092 0x0000000000000000ULL
1093 },
1094 {
1095 0x000000FDFDFDFDFDULL,
1096 0x00000000FDFDFDFDULL,
1097 0x0000000000FDFDFDULL,
1098 0x000000000000FDFDULL,
1099 0x00000000000000FDULL,
1100 0x0000000000000000ULL,
1101 0x0000000000000000ULL,
1102 0x0000000000000000ULL
1103 },
1104 {
1105 0x0000FDFDFDFDFDFDULL,
1106 0x000000FDFDFDFDFDULL,
1107 0x00000000FDFDFDFDULL,
1108 0x0000000000FDFDFDULL,
1109 0x000000000000FDFDULL,
1110 0x00000000000000FDULL,
1111 0x0000000000000000ULL,
1112 0x0000000000000000ULL
1113 },
1114 {
1115 0x00FDFDFDFDFDFDFDULL,
1116 0x0000FDFDFDFDFDFDULL,
1117 0x000000FDFDFDFDFDULL,
1118 0x00000000FDFDFDFDULL,
1119 0x0000000000FDFDFDULL,
1120 0x000000000000FDFDULL,
1121 0x00000000000000FDULL,
1122 0x0000000000000000ULL
1123 },
1124 {
1125 0xFDFDFDFDFDFDFDFDULL,
1126 0x00FDFDFDFDFDFDFDULL,
1127 0x0000FDFDFDFDFDFDULL,
1128 0x000000FDFDFDFDFDULL,
1129 0x00000000FDFDFDFDULL,
1130 0x0000000000FDFDFDULL,
1131 0x000000000000FDFDULL,
1132 0x00000000000000FDULL
1133 },
1134 {
1135 0xFDFDFDFDFDFDFDFDULL,
1136 0xFDFDFDFDFDFDFDFDULL,
1137 0x00FDFDFDFDFDFDFDULL,
1138 0x0000FDFDFDFDFDFDULL,
1139 0x000000FDFDFDFDFDULL,
1140 0x00000000FDFDFDFDULL,
1141 0x0000000000FDFDFDULL,
1142 0x000000000000FDFDULL
1143 },
1144 {
1145 0xFDFDFDFDFDFDFDFDULL,
1146 0xFDFDFDFDFDFDFDFDULL,
1147 0xFDFDFDFDFDFDFDFDULL,
1148 0x00FDFDFDFDFDFDFDULL,
1149 0x0000FDFDFDFDFDFDULL,
1150 0x000000FDFDFDFDFDULL,
1151 0x00000000FDFDFDFDULL,
1152 0x0000000000FDFDFDULL
1153 },
1154 {
1155 0xFDFDFDFDFDFDFDFDULL,
1156 0xFDFDFDFDFDFDFDFDULL,
1157 0xFDFDFDFDFDFDFDFDULL,
1158 0xFDFDFDFDFDFDFDFDULL,
1159 0x00FDFDFDFDFDFDFDULL,
1160 0x0000FDFDFDFDFDFDULL,
1161 0x000000FDFDFDFDFDULL,
1162 0x00000000FDFDFDFDULL
1163 },
1164 {
1165 0xFDFDFDFDFDFDFDFDULL,
1166 0xFDFDFDFDFDFDFDFDULL,
1167 0xFDFDFDFDFDFDFDFDULL,
1168 0xFDFDFDFDFDFDFDFDULL,
1169 0xFDFDFDFDFDFDFDFDULL,
1170 0x00FDFDFDFDFDFDFDULL,
1171 0x0000FDFDFDFDFDFDULL,
1172 0x000000FDFDFDFDFDULL
1173 },
1174 {
1175 0xFDFDFDFDFDFDFDFDULL,
1176 0xFDFDFDFDFDFDFDFDULL,
1177 0xFDFDFDFDFDFDFDFDULL,
1178 0xFDFDFDFDFDFDFDFDULL,
1179 0xFDFDFDFDFDFDFDFDULL,
1180 0xFDFDFDFDFDFDFDFDULL,
1181 0x00FDFDFDFDFDFDFDULL,
1182 0x0000FDFDFDFDFDFDULL
1183 },
1184 {
1185 0xFDFDFDFDFDFDFDFDULL,
1186 0xFDFDFDFDFDFDFDFDULL,
1187 0xFDFDFDFDFDFDFDFDULL,
1188 0xFDFDFDFDFDFDFDFDULL,
1189 0xFDFDFDFDFDFDFDFDULL,
1190 0xFDFDFDFDFDFDFDFDULL,
1191 0xFDFDFDFDFDFDFDFDULL,
1192 0x00FDFDFDFDFDFDFDULL
1193 },
1194 {
1195 0xFDFDFDFDFDFDFDFDULL,
1196 0xFDFDFDFDFDFDFDFDULL,
1197 0xFDFDFDFDFDFDFDFDULL,
1198 0xFDFDFDFDFDFDFDFDULL,
1199 0xFDFDFDFDFDFDFDFDULL,
1200 0xFDFDFDFDFDFDFDFDULL,
1201 0xFDFDFDFDFDFDFDFDULL,
1202 0xFDFDFDFDFDFDFDFDULL
1203 }
1204 },
1205 {
1206 {
1207 0x0000000000000000ULL,
1208 0x0000000000000000ULL,
1209 0x0000000000000000ULL,
1210 0x0000000000000000ULL,
1211 0x0000000000000000ULL,
1212 0x0000000000000000ULL,
1213 0x0000000000000000ULL,
1214 0x0000000000000000ULL
1215 },
1216 {
1217 0x0000000000000000ULL,
1218 0x0000000000000000ULL,
1219 0x0000000000000000ULL,
1220 0x0000000000000000ULL,
1221 0x0000000000000000ULL,
1222 0x0000000000000000ULL,
1223 0x0000000000000000ULL,
1224 0xFD00000000000000ULL
1225 },
1226 {
1227 0x0000000000000000ULL,
1228 0x0000000000000000ULL,
1229 0x0000000000000000ULL,
1230 0x0000000000000000ULL,
1231 0x0000000000000000ULL,
1232 0x0000000000000000ULL,
1233 0xFD00000000000000ULL,
1234 0xFDFD000000000000ULL
1235 },
1236 {
1237 0x0000000000000000ULL,
1238 0x0000000000000000ULL,
1239 0x0000000000000000ULL,
1240 0x0000000000000000ULL,
1241 0x0000000000000000ULL,
1242 0xFD00000000000000ULL,
1243 0xFDFD000000000000ULL,
1244 0xFDFDFD0000000000ULL
1245 },
1246 {
1247 0x0000000000000000ULL,
1248 0x0000000000000000ULL,
1249 0x0000000000000000ULL,
1250 0x0000000000000000ULL,
1251 0xFD00000000000000ULL,
1252 0xFDFD000000000000ULL,
1253 0xFDFDFD0000000000ULL,
1254 0xFDFDFDFD00000000ULL
1255 },
1256 {
1257 0x0000000000000000ULL,
1258 0x0000000000000000ULL,
1259 0x0000000000000000ULL,
1260 0xFD00000000000000ULL,
1261 0xFDFD000000000000ULL,
1262 0xFDFDFD0000000000ULL,
1263 0xFDFDFDFD00000000ULL,
1264 0xFDFDFDFDFD000000ULL
1265 },
1266 {
1267 0x0000000000000000ULL,
1268 0x0000000000000000ULL,
1269 0xFD00000000000000ULL,
1270 0xFDFD000000000000ULL,
1271 0xFDFDFD0000000000ULL,
1272 0xFDFDFDFD00000000ULL,
1273 0xFDFDFDFDFD000000ULL,
1274 0xFDFDFDFDFDFD0000ULL
1275 },
1276 {
1277 0x0000000000000000ULL,
1278 0xFD00000000000000ULL,
1279 0xFDFD000000000000ULL,
1280 0xFDFDFD0000000000ULL,
1281 0xFDFDFDFD00000000ULL,
1282 0xFDFDFDFDFD000000ULL,
1283 0xFDFDFDFDFDFD0000ULL,
1284 0xFDFDFDFDFDFDFD00ULL
1285 },
1286 {
1287 0xFD00000000000000ULL,
1288 0xFDFD000000000000ULL,
1289 0xFDFDFD0000000000ULL,
1290 0xFDFDFDFD00000000ULL,
1291 0xFDFDFDFDFD000000ULL,
1292 0xFDFDFDFDFDFD0000ULL,
1293 0xFDFDFDFDFDFDFD00ULL,
1294 0xFDFDFDFDFDFDFDFDULL
1295 },
1296 {
1297 0xFDFD000000000000ULL,
1298 0xFDFDFD0000000000ULL,
1299 0xFDFDFDFD00000000ULL,
1300 0xFDFDFDFDFD000000ULL,
1301 0xFDFDFDFDFDFD0000ULL,
1302 0xFDFDFDFDFDFDFD00ULL,
1303 0xFDFDFDFDFDFDFDFDULL,
1304 0xFDFDFDFDFDFDFDFDULL
1305 },
1306 {
1307 0xFDFDFD0000000000ULL,
1308 0xFDFDFDFD00000000ULL,
1309 0xFDFDFDFDFD000000ULL,
1310 0xFDFDFDFDFDFD0000ULL,
1311 0xFDFDFDFDFDFDFD00ULL,
1312 0xFDFDFDFDFDFDFDFDULL,
1313 0xFDFDFDFDFDFDFDFDULL,
1314 0xFDFDFDFDFDFDFDFDULL
1315 },
1316 {
1317 0xFDFDFDFD00000000ULL,
1318 0xFDFDFDFDFD000000ULL,
1319 0xFDFDFDFDFDFD0000ULL,
1320 0xFDFDFDFDFDFDFD00ULL,
1321 0xFDFDFDFDFDFDFDFDULL,
1322 0xFDFDFDFDFDFDFDFDULL,
1323 0xFDFDFDFDFDFDFDFDULL,
1324 0xFDFDFDFDFDFDFDFDULL
1325 },
1326 {
1327 0xFDFDFDFDFD000000ULL,
1328 0xFDFDFDFDFDFD0000ULL,
1329 0xFDFDFDFDFDFDFD00ULL,
1330 0xFDFDFDFDFDFDFDFDULL,
1331 0xFDFDFDFDFDFDFDFDULL,
1332 0xFDFDFDFDFDFDFDFDULL,
1333 0xFDFDFDFDFDFDFDFDULL,
1334 0xFDFDFDFDFDFDFDFDULL
1335 },
1336 {
1337 0xFDFDFDFDFDFD0000ULL,
1338 0xFDFDFDFDFDFDFD00ULL,
1339 0xFDFDFDFDFDFDFDFDULL,
1340 0xFDFDFDFDFDFDFDFDULL,
1341 0xFDFDFDFDFDFDFDFDULL,
1342 0xFDFDFDFDFDFDFDFDULL,
1343 0xFDFDFDFDFDFDFDFDULL,
1344 0xFDFDFDFDFDFDFDFDULL
1345 },
1346 {
1347 0xFDFDFDFDFDFDFD00ULL,
1348 0xFDFDFDFDFDFDFDFDULL,
1349 0xFDFDFDFDFDFDFDFDULL,
1350 0xFDFDFDFDFDFDFDFDULL,
1351 0xFDFDFDFDFDFDFDFDULL,
1352 0xFDFDFDFDFDFDFDFDULL,
1353 0xFDFDFDFDFDFDFDFDULL,
1354 0xFDFDFDFDFDFDFDFDULL
1355 },
1356 {
1357 0xFDFDFDFDFDFDFDFDULL,
1358 0xFDFDFDFDFDFDFDFDULL,
1359 0xFDFDFDFDFDFDFDFDULL,
1360 0xFDFDFDFDFDFDFDFDULL,
1361 0xFDFDFDFDFDFDFDFDULL,
1362 0xFDFDFDFDFDFDFDFDULL,
1363 0xFDFDFDFDFDFDFDFDULL,
1364 0xFDFDFDFDFDFDFDFDULL
1365 }
1366 },
1367 {
1368 {
1369 0x0000000000000000ULL,
1370 0x0000000000000000ULL,
1371 0x0000000000000000ULL,
1372 0x0000000000000000ULL,
1373 0x0000000000000000ULL,
1374 0x0000000000000000ULL,
1375 0x0000000000000000ULL,
1376 0x0000000000000000ULL
1377 },
1378 {
1379 0x0000000000000000ULL,
1380 0x0000000000000000ULL,
1381 0x0000000000000000ULL,
1382 0x0000000000000000ULL,
1383 0x0000000000000000ULL,
1384 0x0000000000000000ULL,
1385 0x0000000000000000ULL,
1386 0x00000000000000FDULL
1387 },
1388 {
1389 0x0000000000000000ULL,
1390 0x0000000000000000ULL,
1391 0x0000000000000000ULL,
1392 0x0000000000000000ULL,
1393 0x0000000000000000ULL,
1394 0x0000000000000000ULL,
1395 0x00000000000000FDULL,
1396 0x000000000000FDFDULL
1397 },
1398 {
1399 0x0000000000000000ULL,
1400 0x0000000000000000ULL,
1401 0x0000000000000000ULL,
1402 0x0000000000000000ULL,
1403 0x0000000000000000ULL,
1404 0x00000000000000FDULL,
1405 0x000000000000FDFDULL,
1406 0x0000000000FDFDFDULL
1407 },
1408 {
1409 0x0000000000000000ULL,
1410 0x0000000000000000ULL,
1411 0x0000000000000000ULL,
1412 0x0000000000000000ULL,
1413 0x00000000000000FDULL,
1414 0x000000000000FDFDULL,
1415 0x0000000000FDFDFDULL,
1416 0x00000000FDFDFDFDULL
1417 },
1418 {
1419 0x0000000000000000ULL,
1420 0x0000000000000000ULL,
1421 0x0000000000000000ULL,
1422 0x00000000000000FDULL,
1423 0x000000000000FDFDULL,
1424 0x0000000000FDFDFDULL,
1425 0x00000000FDFDFDFDULL,
1426 0x000000FDFDFDFDFDULL
1427 },
1428 {
1429 0x0000000000000000ULL,
1430 0x0000000000000000ULL,
1431 0x00000000000000FDULL,
1432 0x000000000000FDFDULL,
1433 0x0000000000FDFDFDULL,
1434 0x00000000FDFDFDFDULL,
1435 0x000000FDFDFDFDFDULL,
1436 0x0000FDFDFDFDFDFDULL
1437 },
1438 {
1439 0x0000000000000000ULL,
1440 0x00000000000000FDULL,
1441 0x000000000000FDFDULL,
1442 0x0000000000FDFDFDULL,
1443 0x00000000FDFDFDFDULL,
1444 0x000000FDFDFDFDFDULL,
1445 0x0000FDFDFDFDFDFDULL,
1446 0x00FDFDFDFDFDFDFDULL
1447 },
1448 {
1449 0x00000000000000FDULL,
1450 0x000000000000FDFDULL,
1451 0x0000000000FDFDFDULL,
1452 0x00000000FDFDFDFDULL,
1453 0x000000FDFDFDFDFDULL,
1454 0x0000FDFDFDFDFDFDULL,
1455 0x00FDFDFDFDFDFDFDULL,
1456 0xFDFDFDFDFDFDFDFDULL
1457 },
1458 {
1459 0x000000000000FDFDULL,
1460 0x0000000000FDFDFDULL,
1461 0x00000000FDFDFDFDULL,
1462 0x000000FDFDFDFDFDULL,
1463 0x0000FDFDFDFDFDFDULL,
1464 0x00FDFDFDFDFDFDFDULL,
1465 0xFDFDFDFDFDFDFDFDULL,
1466 0xFDFDFDFDFDFDFDFDULL
1467 },
1468 {
1469 0x0000000000FDFDFDULL,
1470 0x00000000FDFDFDFDULL,
1471 0x000000FDFDFDFDFDULL,
1472 0x0000FDFDFDFDFDFDULL,
1473 0x00FDFDFDFDFDFDFDULL,
1474 0xFDFDFDFDFDFDFDFDULL,
1475 0xFDFDFDFDFDFDFDFDULL,
1476 0xFDFDFDFDFDFDFDFDULL
1477 },
1478 {
1479 0x00000000FDFDFDFDULL,
1480 0x000000FDFDFDFDFDULL,
1481 0x0000FDFDFDFDFDFDULL,
1482 0x00FDFDFDFDFDFDFDULL,
1483 0xFDFDFDFDFDFDFDFDULL,
1484 0xFDFDFDFDFDFDFDFDULL,
1485 0xFDFDFDFDFDFDFDFDULL,
1486 0xFDFDFDFDFDFDFDFDULL
1487 },
1488 {
1489 0x000000FDFDFDFDFDULL,
1490 0x0000FDFDFDFDFDFDULL,
1491 0x00FDFDFDFDFDFDFDULL,
1492 0xFDFDFDFDFDFDFDFDULL,
1493 0xFDFDFDFDFDFDFDFDULL,
1494 0xFDFDFDFDFDFDFDFDULL,
1495 0xFDFDFDFDFDFDFDFDULL,
1496 0xFDFDFDFDFDFDFDFDULL
1497 },
1498 {
1499 0x0000FDFDFDFDFDFDULL,
1500 0x00FDFDFDFDFDFDFDULL,
1501 0xFDFDFDFDFDFDFDFDULL,
1502 0xFDFDFDFDFDFDFDFDULL,
1503 0xFDFDFDFDFDFDFDFDULL,
1504 0xFDFDFDFDFDFDFDFDULL,
1505 0xFDFDFDFDFDFDFDFDULL,
1506 0xFDFDFDFDFDFDFDFDULL
1507 },
1508 {
1509 0x00FDFDFDFDFDFDFDULL,
1510 0xFDFDFDFDFDFDFDFDULL,
1511 0xFDFDFDFDFDFDFDFDULL,
1512 0xFDFDFDFDFDFDFDFDULL,
1513 0xFDFDFDFDFDFDFDFDULL,
1514 0xFDFDFDFDFDFDFDFDULL,
1515 0xFDFDFDFDFDFDFDFDULL,
1516 0xFDFDFDFDFDFDFDFDULL
1517 },
1518 {
1519 0xFDFDFDFDFDFDFDFDULL,
1520 0xFDFDFDFDFDFDFDFDULL,
1521 0xFDFDFDFDFDFDFDFDULL,
1522 0xFDFDFDFDFDFDFDFDULL,
1523 0xFDFDFDFDFDFDFDFDULL,
1524 0xFDFDFDFDFDFDFDFDULL,
1525 0xFDFDFDFDFDFDFDFDULL,
1526 0xFDFDFDFDFDFDFDFDULL
1527 }
1528 }
1529 };
1530
1531 int32_t black_opening_count=0;
1532 int32_t black_opening_x,black_opening_y;
1533 int32_t black_opening_shape;
1534
1535 3204 int32_t choose_opening_shape()
1536 {
1537 // First, count how many bits are set
1538 3204 int32_t numBits=0;
1539 int32_t bitCounter;
1540
1541
2/2
✓ Branch 0 taken 16020 times.
✓ Branch 1 taken 3204 times.
19224 for(int32_t i=0; i<bosMAX; i++)
1542 {
1543
2/2
✓ Branch 0 taken 12600 times.
✓ Branch 1 taken 3420 times.
16020 if(COOLSCROLL&(1<<i))
1544 3420 numBits++;
1545 16020 }
1546
1547 // Shouldn't happen...
1548
1/2
✓ Branch 0 taken 3204 times.
✗ Branch 1 not taken.
3204 if(numBits==0)
1549 return bosCIRCLE;
1550
1551 // Pick a bit
1552 3204 bitCounter=zc_rand()%numBits+1;
1553
1554
2/2
✓ Branch 0 taken 4395 times.
✓ Branch 1 taken 26 times.
4421 for(int32_t i=0; i<bosMAX; i++)
1555 {
1556 // If this bit is set, decrement the bit counter
1557
2/2
✓ Branch 0 taken 1061 times.
✓ Branch 1 taken 3334 times.
4395 if(COOLSCROLL&(1<<i))
1558 3334 bitCounter--;
1559
1560 // When the counter hits 0, return a value based on
1561 // which bit it stopped on.
1562 // Reminder: enum {bosCIRCLE=0, bosOVAL, bosTRIANGLE, bosSMAS, bosFADEBLACK, bosMAX};
1563
2/2
✓ Branch 0 taken 3178 times.
✓ Branch 1 taken 1217 times.
4395 if(bitCounter==0)
1564 3178 return i;
1565 1217 }
1566
1567 // Shouldn't be necessary, but the compiler might complain, at least
1568 26 return bosCIRCLE;
1569 3204 }
1570
1571 727 void close_black_opening(int32_t x, int32_t y, bool wait, int32_t shape)
1572 {
1573
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 727 times.
727 black_opening_shape= (shape>-1 ? shape : choose_opening_shape());
1574
1575 727 int32_t w=256, h=224;
1576 727 int32_t blockrows=28, blockcolumns=32;
1577 727 int32_t xoffset=(x-(w/2))/8, yoffset=(y-(h/2))/8;
1578
1579
2/2
✓ Branch 0 taken 20356 times.
✓ Branch 1 taken 727 times.
21083 for(int32_t blockrow=0; blockrow<blockrows; ++blockrow) //30
1580 {
1581
2/2
✓ Branch 0 taken 651392 times.
✓ Branch 1 taken 20356 times.
671748 for(int32_t blockcolumn=0; blockcolumn<blockcolumns; ++blockcolumn) //40
1582 {
1583
2/2
✓ Branch 0 taken 269309 times.
✓ Branch 1 taken 382083 times.
651392 screen_triangles[blockrow][blockcolumn]=zc_max(abs(int32_t(double(blockcolumns-1)/2-blockcolumn+xoffset)),abs(int32_t(double(blockrows-1)/2-blockrow+yoffset)))|0x0100|((blockrow-yoffset<blockrows/2)?0:0x8000)|((blockcolumn-xoffset<blockcolumns/2)?0x4000:0);
1584 651392 }
1585 20356 }
1586
1587 727 black_opening_count = 66;
1588 727 black_opening_x = x;
1589 727 black_opening_y = y;
1590 727 lensclk = 0;
1591 //black_opening_shape=(black_opening_shape+1)%bosMAX;
1592
1593
1594
1/2
✓ Branch 0 taken 727 times.
✗ Branch 1 not taken.
727 if(black_opening_shape == bosFADEBLACK)
1595 {
1596 refreshTints();
1597 memcpy(tempblackpal, RAMpal, sizeof(RAMpal)); //Store palette in temp palette for fade effect
1598 }
1599
2/2
✓ Branch 0 taken 723 times.
✓ Branch 1 taken 4 times.
727 if(wait)
1600 {
1601 4 FFCore.warpScriptCheck();
1602
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 264 times.
268 for(int32_t i=0; i<66; i++)
1603 {
1604 264 draw_screen(tmpscr);
1605 //put_passive_subscr(framebuf,0,passive_subscreen_offset,false,sspUP);
1606 264 advanceframe(true);
1607
1608
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 264 times.
264 if(Quit)
1609 {
1610 break;
1611 }
1612 264 }
1613 4 }
1614 727 }
1615
1616 2477 void open_black_opening(int32_t x, int32_t y, bool wait, int32_t shape)
1617 {
1618
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2477 times.
2477 black_opening_shape= (shape>-1 ? shape : choose_opening_shape());
1619
1620 2477 int32_t w=256, h=224;
1621 2477 int32_t blockrows=28, blockcolumns=32;
1622 2477 int32_t xoffset=(x-(w/2))/8, yoffset=(y-(h/2))/8;
1623
1624
2/2
✓ Branch 0 taken 69356 times.
✓ Branch 1 taken 2477 times.
71833 for(int32_t blockrow=0; blockrow<blockrows; ++blockrow) //30
1625 {
1626
2/2
✓ Branch 0 taken 2219392 times.
✓ Branch 1 taken 69356 times.
2288748 for(int32_t blockcolumn=0; blockcolumn<blockcolumns; ++blockcolumn) //40
1627 {
1628
2/2
✓ Branch 0 taken 1095033 times.
✓ Branch 1 taken 1124359 times.
2219392 screen_triangles[blockrow][blockcolumn]=zc_max(abs(int32_t(double(blockcolumns-1)/2-blockcolumn+xoffset)),abs(int32_t(double(blockrows-1)/2-blockrow+yoffset)))|0x0100|((blockrow-yoffset<blockrows/2)?0:0x8000)|((blockcolumn-xoffset<blockcolumns/2)?0x4000:0);
1629 2219392 }
1630 69356 }
1631
1632 2477 black_opening_count = -66;
1633 2477 black_opening_x = x;
1634 2477 black_opening_y = y;
1635 2477 lensclk = 0;
1636
1/2
✓ Branch 0 taken 2477 times.
✗ Branch 1 not taken.
2477 if(black_opening_shape == bosFADEBLACK)
1637 {
1638 refreshTints();
1639 memcpy(tempblackpal, RAMpal, sizeof(RAMpal)); //Store palette in temp palette for fade effect
1640 }
1641
2/2
✓ Branch 0 taken 367 times.
✓ Branch 1 taken 2110 times.
2477 if(wait)
1642 {
1643 2110 FFCore.warpScriptCheck();
1644
2/2
✓ Branch 0 taken 2109 times.
✓ Branch 1 taken 139263 times.
141372 for(int32_t i=0; i<66; i++)
1645 {
1646 139263 draw_screen(tmpscr);
1647 //put_passive_subscr(framebuf,0,passive_subscreen_offset,false,sspUP);
1648 139263 advanceframe(true);
1649
1650
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 139262 times.
139263 if(Quit)
1651 {
1652 1 break;
1653 }
1654 139262 }
1655 2110 }
1656 2477 }
1657
1658 210753 void black_opening(BITMAP *dest,int32_t x,int32_t y,int32_t a,int32_t max_a)
1659 {
1660 210753 clear_to_color(tmp_scr,BLACK);
1661 210753 int32_t w=256, h=224;
1662
1663
4/6
✗ Branch 0 not taken.
✓ Branch 1 taken 9636 times.
✓ Branch 2 taken 660 times.
✓ Branch 3 taken 20262 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 180195 times.
210753 switch(black_opening_shape)
1664 {
1665 case bosOVAL:
1666 {
1667 9636 double new_w=(w/2)+abs(w/2-x);
1668 9636 double new_h=(h/2)+abs(h/2-y);
1669 9636 double b=sqrt(((new_w*new_w)/4)+(new_h*new_h));
1670 9636 ellipsefill(tmp_scr,x,y,int32_t(2*a*b/max_a)/8*8,int32_t(a*b/max_a)/8*8,0);
1671 9636 break;
1672 }
1673
1674 case bosTRIANGLE:
1675 {
1676 660 double new_w=(w/2)+abs(w/2-x);
1677 660 double new_h=(h/2)+abs(h/2-y);
1678 660 double r=a*(new_w*sqrt((double)3)+new_h)/max_a;
1679 660 double P2= (PI/2);
1680 660 double P23=(2*PI/3);
1681 660 double P43=(4*PI/3);
1682 660 double Pa= (-4*PI*a/(3*max_a));
1683 660 double angle=P2+Pa;
1684 660 double a0=angle;
1685 660 double a2=angle+P23;
1686 660 double a4=angle+P43;
1687 1320 triangle(tmp_scr, x+int32_t(zc::math::Cos(a0)*r), y-int32_t(zc::math::Sin(a0)*r),
1688 660 x+int32_t(zc::math::Cos(a2)*r), y-int32_t(zc::math::Sin(a2)*r),
1689 660 x+int32_t(zc::math::Cos(a4)*r), y-int32_t(zc::math::Sin(a4)*r),
1690 0);
1691 660 break;
1692 }
1693
1694 case bosSMAS:
1695 {
1696
2/2
✓ Branch 0 taken 7194 times.
✓ Branch 1 taken 13068 times.
20262 int32_t distance=zc_max(abs(w/2-x),abs(h/2-y))/8;
1697
1698
2/2
✓ Branch 0 taken 567336 times.
✓ Branch 1 taken 20262 times.
587598 for(int32_t blockrow=0; blockrow<28; ++blockrow) //30
1699 {
1700
2/2
✓ Branch 0 taken 4538688 times.
✓ Branch 1 taken 567336 times.
5106024 for(int32_t linerow=0; linerow<8; ++linerow)
1701 {
1702 4538688 qword *triangleline=(qword*)(tmp_scr->line[(blockrow*8+linerow)]);
1703
1704
2/2
✓ Branch 0 taken 145238016 times.
✓ Branch 1 taken 4538688 times.
149776704 for(int32_t blockcolumn=0; blockcolumn<32; ++blockcolumn) //40
1705 {
1706 435714048 *triangleline=triangles[(screen_triangles[blockrow][blockcolumn]&0xC000)>>14]
1707
6/6
✓ Branch 0 taken 104912184 times.
✓ Branch 1 taken 40325832 times.
✓ Branch 2 taken 95821040 times.
✓ Branch 3 taken 49416976 times.
✓ Branch 4 taken 55495208 times.
✓ Branch 5 taken 40325832 times.
145238016 [zc_min(zc_max((((31+distance)*(max_a-a)/max_a)+((screen_triangles[blockrow][blockcolumn]&0x0FFF)-0x0100)-(15+distance)),0),15)]
1708 145238016 [linerow];
1709 145238016 ++triangleline;
1710
1711
2/2
✓ Branch 0 taken 127083264 times.
✓ Branch 1 taken 18154752 times.
145238016 if(linerow==0)
1712 {
1713 18154752 }
1714 145238016 }
1715 4538688 }
1716 567336 }
1717
1718 20262 break;
1719 }
1720
1721 case bosFADEBLACK:
1722 {
1723 if(black_opening_count<0)
1724 {
1725 black_fade(zc_min(-black_opening_count,63));
1726 }
1727 else if(black_opening_count>0)
1728 {
1729 black_fade(63-zc_max(black_opening_count-3,0));
1730 }
1731 else black_fade(0);
1732 return; //no blitting from tmp_scr!
1733 }
1734
1735 180195 case bosCIRCLE:
1736 default:
1737 {
1738 180195 double new_w=(w/2)+abs(w/2-x);
1739 180195 double new_h=(h/2)+abs(h/2-y);
1740 180195 int32_t r=int32_t(sqrt((new_w*new_w)+(new_h*new_h))*a/max_a);
1741 //circlefill(tmp_scr,x,y,a<<3,0);
1742 180195 circlefill(tmp_scr,x,y,r,0);
1743 180195 break;
1744 }
1745 }
1746
1747 210753 masked_blit(tmp_scr,dest,0,0,0,0,320,240);
1748 210753 }
1749
1750 // fadeamnt is 0-63
1751 void black_fade(int32_t fadeamnt)
1752 {
1753 fadeamnt = _rgb_scale_6[fadeamnt];
1754 for(int32_t i=0; i < 0xEF; i++)
1755 {
1756 RAMpal[i].r = vbound(tempblackpal[i].r-fadeamnt,0,255);
1757 RAMpal[i].g = vbound(tempblackpal[i].g-fadeamnt,0,255);
1758 RAMpal[i].b = vbound(tempblackpal[i].b-fadeamnt,0,255);
1759 }
1760
1761 refreshpal = true;
1762 }
1763
1764 //----------------------------------------------------------------
1765
1766 198173060 bool item_disabled(int32_t item) //is this item disabled?
1767 {
1768
2/2
✓ Branch 0 taken 14112335 times.
✓ Branch 1 taken 184060725 times.
198173060 return (unsigned(item) < MAXITEMS && game->items_off[item] != 0);
1769 }
1770
1771 15445683 bool can_use_item(int32_t item_type, int32_t item) //can Hero use this item?
1772 {
1773
2/2
✓ Branch 0 taken 188072 times.
✓ Branch 1 taken 15257611 times.
15445683 if(current_item(item_type, true) >=item)
1774 {
1775 188072 return true;
1776 }
1777
1778 15257611 return false;
1779 15445683 }
1780
1781 48060581 bool has_item(int32_t item_type, int32_t it) //does Hero possess this item?
1782 {
1783
5/9
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✓ Branch 2 taken 4374892 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 4901587 times.
✓ Branch 6 taken 28694835 times.
✓ Branch 7 taken 9894813 times.
✓ Branch 8 taken 194454 times.
48060581 switch(item_type)
1784 {
1785 case itype_bomb:
1786 case itype_sbomb:
1787 {
1788 int32_t itemid = getItemID(itemsbuf, item_type, it);
1789
1790 if(itemid == -1)
1791 return false;
1792
1793 return (game->get_item(itemid));
1794 }
1795
1796 case itype_clock:
1797 {
1798 4374892 int32_t itemid = getItemID(itemsbuf, item_type, it);
1799
1800
2/4
✓ Branch 0 taken 4374892 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 4374892 times.
✗ Branch 3 not taken.
4374892 if(itemid != -1 && (itemsbuf[itemid].flags & item_flag1)) //Active clock
1801 return (game->get_item(itemid));
1802 4374892 return Hero.getClock()?1:0;
1803 }
1804
1805 case itype_key:
1806 return (game->get_keys()>0);
1807
1808 case itype_magiccontainer:
1809 return (game->get_maxmagic()>=game->get_mp_per_block());
1810
1811 case itype_triforcepiece: //it: -2=any, -1=current level, other=that level
1812 {
1813
2/3
✓ Branch 0 taken 321216 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 4580371 times.
4901587 switch(it)
1814 {
1815 case -2:
1816 {
1817 for(int32_t i=0; i<MAXLEVELS; i++)
1818 {
1819 if(game->lvlitems[i]&liTRIFORCE)
1820 {
1821 return true;
1822 }
1823 }
1824
1825 return false;
1826 }
1827
1828 case -1:
1829 4580371 return (game->lvlitems[dlevel]&liTRIFORCE);
1830
1831 default:
1832
2/4
✓ Branch 0 taken 321216 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 321216 times.
321216 if(it>=0&&it<MAXLEVELS)
1833 {
1834 321216 return (game->lvlitems[it]&liTRIFORCE);
1835 }
1836
1837 break;
1838 }
1839
1840 return 0;
1841 }
1842
1843 case itype_map: //it: -2=any, -1=current level, other=that level
1844 {
1845
2/3
✓ Branch 0 taken 540402 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 28154433 times.
28694835 switch(it)
1846 {
1847 case -2:
1848 {
1849 for(int32_t i=0; i<MAXLEVELS; i++)
1850 {
1851 if(game->lvlitems[i]&liMAP)
1852 {
1853 return true;
1854 }
1855 }
1856
1857 return false;
1858 }
1859
1860 case -1:
1861 28154433 return (game->lvlitems[dlevel]&liMAP)!=0;
1862
1863 default:
1864
2/4
✓ Branch 0 taken 540402 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 540402 times.
540402 if(it>=0&&it<MAXLEVELS)
1865 {
1866 540402 return (game->lvlitems[it]&liMAP)!=0;
1867 }
1868
1869 break;
1870 }
1871
1872 return 0;
1873 }
1874
1875 case itype_compass: //it: -2=any, -1=current level, other=that level
1876 {
1877
1/3
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✓ Branch 2 taken 9894813 times.
9894813 switch(it)
1878 {
1879 case -2:
1880 {
1881 for(int32_t i=0; i<MAXLEVELS; i++)
1882 {
1883 if(game->lvlitems[i]&liCOMPASS)
1884 {
1885 return true;
1886 }
1887 }
1888
1889 return false;
1890 }
1891
1892 case -1:
1893 9894813 return (game->lvlitems[dlevel]&liCOMPASS)!=0;
1894
1895 default:
1896 if(it>=0&&it<MAXLEVELS)
1897 {
1898 return (game->lvlitems[it]&liCOMPASS)!=0;
1899 }
1900
1901 break;
1902 }
1903 return 0;
1904 }
1905
1906 case itype_bosskey: //it: -2=any, -1=current level, other=that level
1907 {
1908
1/3
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✓ Branch 2 taken 194454 times.
194454 switch(it)
1909 {
1910 case -2:
1911 {
1912 for(int32_t i=0; i<MAXLEVELS; i++)
1913 {
1914 if(game->lvlitems[i]&liBOSSKEY)
1915 {
1916 return true;
1917 }
1918 }
1919
1920 return false;
1921 }
1922
1923 case -1:
1924 194454 return (game->lvlitems[dlevel]&liBOSSKEY)?1:0;
1925
1926 default:
1927 if(it>=0&&it<MAXLEVELS)
1928 {
1929 return (game->lvlitems[it]&liBOSSKEY)?1:0;
1930 }
1931 break;
1932 }
1933 return 0;
1934 }
1935
1936 default:
1937 int32_t itemid = getItemID(itemsbuf, item_type, it);
1938
1939 if(itemid == -1)
1940 return false;
1941
1942 return game->get_item(itemid);
1943 }
1944 48060581 }
1945
1946 149166239 int current_item(int item_type, bool checkmagic, bool jinx_check, bool check_bunny)
1947 {
1948
9/9
✓ Branch 0 taken 4374892 times.
✓ Branch 1 taken 114167103 times.
✓ Branch 2 taken 4374892 times.
✓ Branch 3 taken 4374892 times.
✓ Branch 4 taken 4374892 times.
✓ Branch 5 taken 4374892 times.
✓ Branch 6 taken 4374892 times.
✓ Branch 7 taken 4374892 times.
✓ Branch 8 taken 4374892 times.
149166239 switch(item_type)
1949 {
1950 case itype_clock:
1951 {
1952 4374892 int maxid = current_item_id(item_type, checkmagic, jinx_check, check_bunny);
1953
1954
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 4374892 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
4374892 if(maxid != -1 && (itemsbuf[maxid].flags & item_flag1)) //Active clock
1955 return itemsbuf[maxid].fam_type;
1956
1957 4374892 return has_item(itype_clock,1) ? 1 : 0;
1958 }
1959
1960 case itype_key:
1961 4374892 return game->get_keys();
1962
1963 case itype_lkey:
1964 4374892 return game->lvlkeys[get_dlevel()];
1965
1966 case itype_magiccontainer:
1967 4374892 return game->get_maxmagic()/game->get_mp_per_block();
1968
1969 case itype_triforcepiece:
1970 {
1971 4374892 int count=0;
1972
1973
2/2
✓ Branch 0 taken 2239944704 times.
✓ Branch 1 taken 4374892 times.
2244319596 for(int i=0; i<MAXLEVELS; i++)
1974 {
1975 2239944704 count+=(game->lvlitems[i]&liTRIFORCE)?1:0;
1976 2239944704 }
1977
1978 4374892 return count;
1979 }
1980
1981 case itype_map:
1982 {
1983 4374892 int count=0;
1984
1985
2/2
✓ Branch 0 taken 2239944704 times.
✓ Branch 1 taken 4374892 times.
2244319596 for(int i=0; i<MAXLEVELS; i++)
1986 {
1987 2239944704 count+=(game->lvlitems[i]&liMAP)?1:0;
1988 2239944704 }
1989
1990 4374892 return count;
1991 }
1992
1993 case itype_compass:
1994 {
1995 4374892 int count=0;
1996
1997
2/2
✓ Branch 0 taken 2239944704 times.
✓ Branch 1 taken 4374892 times.
2244319596 for(int i=0; i<MAXLEVELS; i++)
1998 {
1999 2239944704 count+=(game->lvlitems[i]&liCOMPASS)?1:0;
2000 2239944704 }
2001
2002 4374892 return count;
2003 }
2004
2005 case itype_bosskey:
2006 {
2007 4374892 int count=0;
2008
2009
2/2
✓ Branch 0 taken 2239944704 times.
✓ Branch 1 taken 4374892 times.
2244319596 for(int i=0; i<MAXLEVELS; i++)
2010 {
2011 2239944704 count+=(game->lvlitems[i]&liBOSSKEY)?1:0;
2012 2239944704 }
2013
2014 4374892 return count;
2015 }
2016
2017 default:
2018 114167103 int maxid = current_item_id(item_type, checkmagic, jinx_check, check_bunny);
2019
2020
2/2
✓ Branch 0 taken 81136393 times.
✓ Branch 1 taken 33030710 times.
114167103 if(maxid == -1)
2021 81136393 return 0;
2022
2023 33030710 return itemsbuf[maxid].fam_type;
2024 }
2025 149166239 }
2026
2027 336 std::map<int32_t, int32_t> itemcache;
2028 336 std::map<int32_t, int32_t> itemcache_cost;
2029
2030 void removeFromItemCache(int32_t itemclass)
2031 {
2032 itemcache.erase(itemclass);
2033 itemcache_cost.erase(itemclass);
2034 cache_tile_mod_clear();
2035 }
2036
2037 12391014 void flushItemCache(bool justcost)
2038 {
2039 12391014 itemcache_cost.clear();
2040
2/2
✓ Branch 0 taken 12324745 times.
✓ Branch 1 taken 66269 times.
12391014 if(!justcost)
2041 66269 itemcache.clear();
2042
2/2
✓ Branch 0 taken 5825976 times.
✓ Branch 1 taken 6498769 times.
12324745 else if(replay_version_check(0,19))
2043 5825976 return;
2044
2045 6565038 cache_tile_mod_clear();
2046
2047 //also fix the active subscreen if items were deleted -DD
2048
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6565038 times.
6565038 if(game != NULL)
2049 {
2050 6565038 verifyBothWeapons();
2051 6565038 refresh_subscr_items();
2052 6565038 }
2053 12391014 }
2054
2055 // This is used often, so it should be as direct as possible.
2056 2973790369 int _c_item_id_internal(int itemtype, bool checkmagic, bool jinx_check, bool check_bunny)
2057 {
2058 2973790369 bool use_cost_cache = replay_version_check(19);
2059
2/2
✓ Branch 0 taken 2849499213 times.
✓ Branch 1 taken 124291156 times.
2973790369 if(jinx_check)
2060 {
2061 //special case for shields...
2062
3/4
✓ Branch 0 taken 39618683 times.
✓ Branch 1 taken 84672473 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 39618683 times.
124291156 if (itemtype == itype_shield && !HeroShieldClk())
2063 39618683 jinx_check = false;
2064
4/4
✓ Branch 0 taken 52067520 times.
✓ Branch 1 taken 32604953 times.
✓ Branch 2 taken 10856084 times.
✓ Branch 3 taken 41211436 times.
84672473 else if(!(HeroSwordClk() || HeroItemClk()))
2065 41211436 jinx_check = false; //not jinxed
2066 124291156 }
2067
4/4
✓ Branch 0 taken 114318 times.
✓ Branch 1 taken 2973676051 times.
✓ Branch 2 taken 1853 times.
✓ Branch 3 taken 112465 times.
2973790369 if(!Hero.BunnyClock() || itemtype == itype_pearl) // bunny_check does not apply
2068 2973677904 check_bunny = false;
2069
2/2
✓ Branch 0 taken 2917912163 times.
✓ Branch 1 taken 55878206 times.
2973790369 if(itemtype == itype_ring) checkmagic = true;
2070
4/4
✓ Branch 0 taken 2930329332 times.
✓ Branch 1 taken 43461037 times.
✓ Branch 2 taken 285018705 times.
✓ Branch 3 taken 23758619 times.
3282567693 if (!jinx_check && !check_bunny
2071
4/4
✓ Branch 0 taken 2930244475 times.
✓ Branch 1 taken 84857 times.
✓ Branch 2 taken 308777324 times.
✓ Branch 3 taken 2621467151 times.
2930329332 && (use_cost_cache || itemtype != itype_ring))
2072 {
2073
4/4
✓ Branch 0 taken 555039199 times.
✓ Branch 1 taken 2351446657 times.
✓ Branch 2 taken 243209268 times.
✓ Branch 3 taken 311829931 times.
2906485856 auto& cache = checkmagic && use_cost_cache ? itemcache_cost : itemcache;
2074 2906485856 auto res = cache.find(itemtype);
2075
2076
2/2
✓ Branch 0 taken 2762874149 times.
✓ Branch 1 taken 143611707 times.
2906485856 if(res != cache.end())
2077 2762874149 return res->second;
2078 143611707 }
2079
2080 210916220 int result = -1;
2081 210916220 int highestlevel = -1;
2082
2083
2/2
✓ Branch 0 taken 53994552320 times.
✓ Branch 1 taken 210916220 times.
54205468540 for(int i=0; i<MAXITEMS; i++)
2084 {
2085
6/6
✓ Branch 0 taken 5922085827 times.
✓ Branch 1 taken 48072466493 times.
✓ Branch 2 taken 95523707 times.
✓ Branch 3 taken 5826562120 times.
✓ Branch 4 taken 82048 times.
✓ Branch 5 taken 95441659 times.
53994552320 if(game->get_item(i) && itemsbuf[i].family==itemtype && !item_disabled(i))
2086 {
2087
4/4
✓ Branch 0 taken 90829065 times.
✓ Branch 1 taken 4612594 times.
✓ Branch 2 taken 2427248 times.
✓ Branch 3 taken 88401817 times.
95441659 if(checkmagic && itemtype != itype_magicring)
2088
2/2
✓ Branch 0 taken 88401200 times.
✓ Branch 1 taken 617 times.
88401817 if(!checkmagiccost(i))
2089 617 continue;
2090
6/6
✓ Branch 0 taken 87845631 times.
✓ Branch 1 taken 7595411 times.
✓ Branch 2 taken 1253626 times.
✓ Branch 3 taken 6341785 times.
✓ Branch 4 taken 4146834 times.
✓ Branch 5 taken 3448577 times.
95441042 if(jinx_check && (usesSwordJinx(i) ? HeroSwordClk() : HeroItemClk()))
2091
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3448577 times.
3448577 if(!(itemsbuf[i].flags & item_jinx_immune))
2092 3448577 continue;
2093
3/4
✓ Branch 0 taken 91665 times.
✓ Branch 1 taken 91900800 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 91665 times.
91992465 if(check_bunny && !checkbunny(i))
2094 91665 continue;
2095
2096
2/2
✓ Branch 0 taken 8381135 times.
✓ Branch 1 taken 83519665 times.
91900800 if(itemsbuf[i].fam_type >= highestlevel)
2097 {
2098 83519665 highestlevel = itemsbuf[i].fam_type;
2099 83519665 result=i;
2100 83519665 }
2101 91900800 }
2102 53991011461 }
2103
2104
4/4
✓ Branch 0 taken 167455183 times.
✓ Branch 1 taken 43461037 times.
✓ Branch 2 taken 84857 times.
✓ Branch 3 taken 167370326 times.
210916220 if(!(jinx_check || check_bunny)) //Can't cache jinx_check/check_bunny
2105 {
2106
2/2
✓ Branch 0 taken 127617390 times.
✓ Branch 1 taken 39752936 times.
167370326 if (use_cost_cache)
2107 {
2108
2/2
✓ Branch 0 taken 111890557 times.
✓ Branch 1 taken 15726833 times.
127617390 if (!checkmagic)
2109 15726833 itemcache[itemtype] = result;
2110
6/6
✓ Branch 0 taken 15726833 times.
✓ Branch 1 taken 111890557 times.
✓ Branch 2 taken 659717 times.
✓ Branch 3 taken 15067116 times.
✓ Branch 4 taken 647074 times.
✓ Branch 5 taken 12643 times.
127617390 if (checkmagic || result < 0 || checkmagiccost(result))
2111 127604747 itemcache_cost[itemtype] = result;
2112 127617390 }
2113 else
2114 {
2115 39752936 itemcache[itemtype] = result;
2116 }
2117 167370326 }
2118 210916220 return result;
2119 2973790369 }
2120
2121 // 'jinx_check' indicates that the highest level item *immune to jinxes* should be returned.
2122 2930829460 int current_item_id(int itype, bool checkmagic, bool jinx_check, bool check_bunny)
2123 {
2124
2/4
✓ Branch 0 taken 2930829460 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 2930829460 times.
2930829460 if(itype < 0 || itype >= itype_max) return -1;
2125
1/2
✓ Branch 0 taken 2930829460 times.
✗ Branch 1 not taken.
2930829460 if(game->OverrideItems[itype] > -2)
2126 {
2127 auto ovid = game->OverrideItems[itype];
2128 if(ovid < 0 || ovid >= MAXITEMS)
2129 return -1;
2130 if(itemsbuf[ovid].family == itype)
2131 {
2132 if(itype == itype_magicring)
2133 checkmagic = false;
2134 else if(itype == itype_ring)
2135 checkmagic = true;
2136
2137 if(checkmagic && !checkmagiccost(ovid))
2138 return -1;
2139
2140 if (jinx_check && !checkitem_jinx(ovid))
2141 {
2142 return -1;
2143 }
2144 return ovid;
2145 }
2146 }
2147 2930829460 auto ret = _c_item_id_internal(itype,checkmagic,jinx_check,check_bunny);
2148
2/2
✓ Branch 0 taken 81330247 times.
✓ Branch 1 taken 2849499213 times.
2930829460 if(!jinx_check) //If not already a jinx-immune-only check...
2149 {
2150 //And the player IS jinxed...
2151
2/2
✓ Branch 0 taken 2806538304 times.
✓ Branch 1 taken 42960909 times.
2849499213 if(HeroIsJinxed())
2152 {
2153 //Then do a jinx-immune-only check here
2154 42960909 auto ret2 = _c_item_id_internal(itype,checkmagic,true,check_bunny);
2155 //And *IF IT FINDS A VALID ITEM*, return that one instead! -Em
2156 //Should NOT need a compat rule, as this should always return -1 in old quests.
2157
2/2
✓ Branch 0 taken 3265892 times.
✓ Branch 1 taken 39695017 times.
42960909 if(ret2 > -1) return ret2;
2158 39695017 }
2159 2846233321 }
2160 2927563568 return ret;
2161 2930829460 }
2162
2163 64796912 int current_item_power(int itemtype, bool checkmagic, bool jinx_check, bool check_bunny)
2164 {
2165 64796912 int result = current_item_id(itemtype, checkmagic, jinx_check, check_bunny);
2166
2/2
✓ Branch 0 taken 35028837 times.
✓ Branch 1 taken 29768075 times.
64796912 return (result<0) ? 0 : itemsbuf[result].power;
2167 }
2168
2169 26 int32_t heart_container_id()
2170 {
2171
1/2
✓ Branch 0 taken 754 times.
✗ Branch 1 not taken.
754 for(int32_t i=0; i<MAXITEMS; i++)
2172 {
2173
2/2
✓ Branch 0 taken 26 times.
✓ Branch 1 taken 728 times.
754 if(itemsbuf[i].family == itype_heartcontainer)
2174 {
2175 26 return i;
2176 }
2177 728 }
2178 return -1;
2179 26 }
2180
2181 struct tilemod_cache_state_t
2182 {
2183
6/6
✓ Branch 0 taken 4374537 times.
✓ Branch 1 taken 8400992 times.
✓ Branch 2 taken 2 times.
✓ Branch 3 taken 8400990 times.
✓ Branch 4 taken 353 times.
✓ Branch 5 taken 8400637 times.
21176521 bool operator==(const tilemod_cache_state_t&) const = default;
2184
2185 bool valid;
2186 bool bunny_clock;
2187 bool superman;
2188 int shield;
2189 };
2190 tilemod_cache_state_t tilemod_cache_state;
2191 int32_t tilemod_cache_value;
2192
2193 6566431 void cache_tile_mod_clear()
2194 {
2195 6566431 tilemod_cache_state = {false};
2196 6566431 }
2197
2198 12775529 int32_t item_tile_mod()
2199 {
2200 51102116 tilemod_cache_state_t state = {
2201 .valid = true,
2202 12775529 .bunny_clock = Hero.BunnyClock() != 0,
2203 12775529 .superman = Hero.superman,
2204 12775529 .shield = Hero.active_shield_id,
2205 };
2206
2/2
✓ Branch 0 taken 8400637 times.
✓ Branch 1 taken 4374892 times.
12775529 if (tilemod_cache_state == state)
2207 8400637 return tilemod_cache_value;
2208
2209 4374892 int32_t tile=0;
2210 4374892 bool check_bombcost = !get_qr(qr_BROKEN_BOMB_AMMO_COSTS);
2211
4/4
✓ Branch 0 taken 3961655 times.
✓ Branch 1 taken 413237 times.
✓ Branch 2 taken 3042145 times.
✓ Branch 3 taken 919510 times.
4374892 if(check_bombcost || game->get_bombs())
2212 {
2213 3455382 int32_t itemid = current_item_id(itype_bomb,check_bombcost);
2214
3/4
✓ Branch 0 taken 3395909 times.
✓ Branch 1 taken 59473 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 3395909 times.
3455382 if(itemid > -1 && checkbunny(itemid))
2215 3395909 tile+=itemsbuf[itemid].ltm;
2216 3455382 }
2217
2218
4/4
✓ Branch 0 taken 3961655 times.
✓ Branch 1 taken 413237 times.
✓ Branch 2 taken 928295 times.
✓ Branch 3 taken 3033360 times.
4374892 if(check_bombcost || game->get_sbombs())
2219 {
2220 1341532 int32_t itemid = current_item_id(itype_sbomb,check_bombcost);
2221
3/4
✓ Branch 0 taken 928054 times.
✓ Branch 1 taken 413478 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 928054 times.
1341532 if(itemid > -1 && checkbunny(itemid))
2222 928054 tile+=itemsbuf[itemid].ltm;
2223 1341532 }
2224
2225
2/2
✓ Branch 0 taken 4370289 times.
✓ Branch 1 taken 4603 times.
4374892 if(current_item(itype_clock))
2226 {
2227 4603 int32_t itemid =
2228
2/2
✓ Branch 0 taken 4594 times.
✓ Branch 1 taken 9 times.
4603 get_qr(qr_HARDCODED_LITEM_LTMS)
2229 ? iClock
2230 9 : getHighestLevelEvenUnowned(itemsbuf, itype_clock);
2231
2/4
✓ Branch 0 taken 4603 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 4603 times.
4603 if(itemid > -1 && checkbunny(itemid))
2232 4603 tile+=itemsbuf[itemid].ltm;
2233 4603 }
2234
2235
2/2
✓ Branch 0 taken 3766252 times.
✓ Branch 1 taken 608640 times.
4374892 if(current_item(itype_key))
2236 {
2237 608640 int32_t itemid =
2238
1/2
✓ Branch 0 taken 608640 times.
✗ Branch 1 not taken.
608640 get_qr(qr_HARDCODED_LITEM_LTMS)
2239 ? iKey
2240 : getHighestLevelEvenUnowned(itemsbuf, itype_key);
2241
2/4
✓ Branch 0 taken 608640 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 608640 times.
608640 if(itemid > -1 && checkbunny(itemid))
2242 608640 tile+=itemsbuf[itemid].ltm;
2243 608640 }
2244
2245
2/2
✓ Branch 0 taken 3874032 times.
✓ Branch 1 taken 500860 times.
4374892 if(current_item(itype_lkey))
2246 {
2247 500860 int32_t itemid =
2248
2/2
✓ Branch 0 taken 414146 times.
✓ Branch 1 taken 86714 times.
500860 get_qr(qr_HARDCODED_LITEM_LTMS)
2249 ? iLevelKey
2250 86714 : getHighestLevelEvenUnowned(itemsbuf, itype_lkey);
2251
2/4
✓ Branch 0 taken 500860 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 500860 times.
500860 if(itemid > -1 && checkbunny(itemid))
2252 500860 tile+=itemsbuf[itemid].ltm;
2253 500860 }
2254
2255
2/2
✓ Branch 0 taken 1540424 times.
✓ Branch 1 taken 2834468 times.
4374892 if(current_item(itype_map))
2256 {
2257 2834468 int32_t itemid =
2258
2/2
✓ Branch 0 taken 2823834 times.
✓ Branch 1 taken 10634 times.
2834468 get_qr(qr_HARDCODED_LITEM_LTMS)
2259 ? iMap
2260 10634 : getHighestLevelEvenUnowned(itemsbuf, itype_map);
2261
2/4
✓ Branch 0 taken 2834468 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 2834468 times.
2834468 if(itemid > -1 && checkbunny(itemid))
2262 2834468 tile+=itemsbuf[itemid].ltm;
2263 2834468 }
2264
2265
2/2
✓ Branch 0 taken 2062903 times.
✓ Branch 1 taken 2311989 times.
4374892 if(current_item(itype_compass))
2266 {
2267 2311989 int32_t itemid =
2268
2/2
✓ Branch 0 taken 2295941 times.
✓ Branch 1 taken 16048 times.
2311989 get_qr(qr_HARDCODED_LITEM_LTMS)
2269 ? iCompass
2270 16048 : getHighestLevelEvenUnowned(itemsbuf, itype_compass);
2271
2/4
✓ Branch 0 taken 2311989 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 2311989 times.
2311989 if(itemid > -1 && checkbunny(itemid))
2272 2311989 tile+=itemsbuf[itemid].ltm;
2273 2311989 }
2274
2275
2/2
✓ Branch 0 taken 1288476 times.
✓ Branch 1 taken 3086416 times.
4374892 if(current_item(itype_bosskey))
2276 {
2277 3086416 int32_t itemid =
2278
2/2
✓ Branch 0 taken 2993139 times.
✓ Branch 1 taken 93277 times.
3086416 get_qr(qr_HARDCODED_LITEM_LTMS)
2279 ? iBossKey
2280 93277 : getHighestLevelEvenUnowned(itemsbuf, itype_bosskey);
2281
2/4
✓ Branch 0 taken 3086416 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 3086416 times.
3086416 if(itemid > -1 && checkbunny(itemid))
2282 3086416 tile+=itemsbuf[itemid].ltm;
2283 3086416 }
2284
2285
2/2
✓ Branch 0 taken 48201 times.
✓ Branch 1 taken 4326691 times.
4374892 if(current_item(itype_magiccontainer))
2286 {
2287 4326691 int32_t itemid =
2288
2/2
✓ Branch 0 taken 3895892 times.
✓ Branch 1 taken 430799 times.
4326691 get_qr(qr_HARDCODED_LITEM_LTMS)
2289 ? iMagicC
2290 430799 : getHighestLevelEvenUnowned(itemsbuf, itype_magiccontainer);
2291
3/4
✓ Branch 0 taken 4326691 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 17 times.
✓ Branch 3 taken 4326674 times.
4326691 if(itemid > -1 && checkbunny(itemid))
2292 4326674 tile+=itemsbuf[itemid].ltm;
2293 4326691 }
2294
2295
2/2
✓ Branch 0 taken 1305414 times.
✓ Branch 1 taken 3069478 times.
4374892 if(current_item(itype_triforcepiece))
2296 {
2297 3069478 int32_t itemid =
2298
1/2
✓ Branch 0 taken 3069478 times.
✗ Branch 1 not taken.
3069478 get_qr(qr_HARDCODED_LITEM_LTMS)
2299 ? iTriforce
2300 : getHighestLevelEvenUnowned(itemsbuf, itype_triforcepiece);
2301
2/4
✓ Branch 0 taken 3069478 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 3069478 times.
3069478 if(itemid > -1 && checkbunny(itemid))
2302 3069478 tile+=itemsbuf[itemid].ltm;
2303 3069478 }
2304
2305
2/2
✓ Branch 0 taken 2239944704 times.
✓ Branch 1 taken 4374892 times.
2244319596 for(int32_t i=0; i<itype_max; i++)
2306 {
2307
2/2
✓ Branch 0 taken 2019299328 times.
✓ Branch 1 taken 220645376 times.
2239944704 if(!get_qr(qr_HARDCODED_LITEM_LTMS))
2308 {
2309
2/2
✓ Branch 0 taken 4309480 times.
✓ Branch 1 taken 216335896 times.
220645376 switch(i)
2310 {
2311 case itype_bomb:
2312 case itype_sbomb:
2313 case itype_clock:
2314 case itype_key:
2315 case itype_lkey:
2316 case itype_map:
2317 case itype_compass:
2318 case itype_bosskey:
2319 case itype_magiccontainer:
2320 case itype_triforcepiece:
2321 4309480 continue; //already handled
2322 }
2323 216335896 }
2324 2235635224 int32_t itemid = current_item_id(i,false);
2325
2/2
✓ Branch 0 taken 2231260332 times.
✓ Branch 1 taken 4374892 times.
2235635224 if(i == itype_shield)
2326 4374892 itemid = getCurrentShield(false);
2327
2328
4/4
✓ Branch 0 taken 114074356 times.
✓ Branch 1 taken 2121560868 times.
✓ Branch 2 taken 1 times.
✓ Branch 3 taken 114074355 times.
2235635224 if(itemid < 0 || !checkbunny(itemid))
2329 2121560869 continue;
2330
2331 114074355 itemdata const& itm = itemsbuf[itemid];
2332
2333
2/2
✓ Branch 0 taken 110411502 times.
✓ Branch 1 taken 3662853 times.
114074355 switch(itm.family)
2334 {
2335 case itype_shield:
2336
1/2
✓ Branch 0 taken 3662853 times.
✗ Branch 1 not taken.
3662853 if(itm.flags & item_flag9) //active shield
2337 {
2338 if(!usingActiveShield(itemid))
2339 {
2340 tile+=itm.misc6; //'Inactive PTM'
2341 continue;
2342 }
2343 }
2344 3662853 break;
2345 }
2346
2347 114074355 tile+=itm.ltm;
2348 114074355 }
2349
2350 4374892 tilemod_cache_value = tile;
2351 4374892 tilemod_cache_state = state;
2352 4374892 return tile;
2353 12775529 }
2354
2355 12775529 int32_t bunny_tile_mod()
2356 {
2357
2/2
✓ Branch 0 taken 1870 times.
✓ Branch 1 taken 12773659 times.
12775529 if(Hero.BunnyClock())
2358 {
2359 1870 return game->get_bunny_ltm();
2360 }
2361 12773659 return 0;
2362 12775529 }
2363
2364 // Hints are drawn on a separate layer to combo reveals.
2365 20010 void draw_lens_under(BITMAP *dest, bool layer)
2366 {
2367 //Lens flag 1: Replacement for qr_LENSHINTS; if set, lens will show hints. Does nothing if flag 2 is set.
2368 //Lens flag 2: Disable "hints", prevent rendering of Secret Combos
2369 //Lens flag 3: Don't show armos/chest/dive items
2370 //Lens flag 4: Show Raft Paths
2371 //Lens flag 5: Show Invisible Enemies
2372
4/4
✓ Branch 0 taken 456 times.
✓ Branch 1 taken 19554 times.
✓ Branch 2 taken 9777 times.
✓ Branch 3 taken 9777 times.
20010 bool hints = (itemsbuf[Hero.getLastLensID()].flags & item_flag2) ? false : (layer && (itemsbuf[Hero.getLastLensID()].flags & item_flag1));
2373
2374 20010 int32_t strike_hint_table[11]=
2375 {
2376 mfARROW, mfBOMB, mfBRANG, mfWANDMAGIC,
2377 mfSWORD, mfREFMAGIC, mfHOOKSHOT,
2378 mfREFFIREBALL, mfHAMMER, mfSWORDBEAM, mfWAND
2379 };
2380
2381 {
2382 20010 int32_t blink_rate=flash_reduction_enabled()?6:1;
2383 20010 int32_t tempitem, tempweapon=0;
2384 20010 strike_hint=strike_hint_table[strike_hint_counter];
2385
2386
2/2
✓ Branch 0 taken 19412 times.
✓ Branch 1 taken 598 times.
20010 if(strike_hint_timer>32)
2387 {
2388 598 strike_hint_timer=0;
2389 598 strike_hint_counter=((strike_hint_counter+1)%11);
2390 598 }
2391
2392 20010 ++strike_hint_timer;
2393
2394
2/2
✓ Branch 0 taken 3521760 times.
✓ Branch 1 taken 20010 times.
3541770 for(int32_t i=0; i<176; i++)
2395 {
2396 3521760 int32_t x = (i & 15) << 4;
2397 3521760 int32_t y = (i & 0xF0) + playing_field_offset;
2398 3521760 int32_t tempitemx=-16, tempitemy=-16;
2399 3521760 int32_t tempweaponx=-16, tempweapony=-16;
2400
2401
2/2
✓ Branch 0 taken 7043520 times.
✓ Branch 1 taken 3521760 times.
10565280 for(int32_t iter=0; iter<2; ++iter)
2402 {
2403 7043520 int32_t checkflag=0;
2404
2405
2/2
✓ Branch 0 taken 3521760 times.
✓ Branch 1 taken 3521760 times.
7043520 if(iter==0)
2406 {
2407 3521760 checkflag=combobuf[tmpscr->data[i]].flag;
2408 3521760 }
2409 else
2410 {
2411 3521760 checkflag=tmpscr->sflag[i];
2412 }
2413
2414
2/2
✓ Branch 0 taken 7042422 times.
✓ Branch 1 taken 1098 times.
7043520 if(checkflag==mfSTRIKE)
2415 {
2416
2/2
✓ Branch 0 taken 192 times.
✓ Branch 1 taken 906 times.
1098 if(!hints)
2417 {
2418
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 906 times.
906 if(!(itemsbuf[Hero.getLastLensID()].flags & item_flag2))putcombo(dest,x,y,tmpscr->secretcombo[sSTRIKE],tmpscr->secretcset[sSTRIKE]);
2419 906 }
2420 else
2421 {
2422 192 checkflag = strike_hint;
2423 }
2424 1098 }
2425
2426
21/36
✓ Branch 0 taken 6894870 times.
✓ Branch 1 taken 3258 times.
✓ Branch 2 taken 108898 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 2602 times.
✓ Branch 5 taken 28750 times.
✓ Branch 6 taken 2418 times.
✓ Branch 7 taken 504 times.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✓ Branch 11 taken 814 times.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✓ Branch 14 taken 93 times.
✓ Branch 15 taken 96 times.
✓ Branch 16 taken 24 times.
✓ Branch 17 taken 25 times.
✗ Branch 18 not taken.
✗ Branch 19 not taken.
✓ Branch 20 taken 138 times.
✓ Branch 21 taken 16 times.
✓ Branch 22 taken 16 times.
✓ Branch 23 taken 7 times.
✗ Branch 24 not taken.
✗ Branch 25 not taken.
✗ Branch 26 not taken.
✓ Branch 27 taken 16 times.
✗ Branch 28 not taken.
✗ Branch 29 not taken.
✗ Branch 30 not taken.
✓ Branch 31 taken 17 times.
✓ Branch 32 taken 35 times.
✓ Branch 33 taken 17 times.
✗ Branch 34 not taken.
✓ Branch 35 taken 906 times.
7043520 switch(checkflag)
2427 {
2428 case 0:
2429 case mfZELDA:
2430 case mfPUSHED:
2431 case mfENEMY0:
2432 case mfENEMY1:
2433 case mfENEMY2:
2434 case mfENEMY3:
2435 case mfENEMY4:
2436 case mfENEMY5:
2437 case mfENEMY6:
2438 case mfENEMY7:
2439 case mfENEMY8:
2440 case mfENEMY9:
2441 case mfSINGLE:
2442 case mfSINGLE16:
2443 case mfNOENEMY:
2444 case mfTRAP_H:
2445 case mfTRAP_V:
2446 case mfTRAP_4:
2447 case mfTRAP_LR:
2448 case mfTRAP_UD:
2449 case mfNOGROUNDENEMY:
2450 case mfNOBLOCKS:
2451 case mfSCRIPT1:
2452 case mfSCRIPT2:
2453 case mfSCRIPT3:
2454 case mfSCRIPT4:
2455 case mfSCRIPT5:
2456 case mfSCRIPT6:
2457 case mfSCRIPT7:
2458 case mfSCRIPT8:
2459 case mfSCRIPT9:
2460 case mfSCRIPT10:
2461 case mfSCRIPT11:
2462 case mfSCRIPT12:
2463 case mfSCRIPT13:
2464 case mfSCRIPT14:
2465 case mfSCRIPT15:
2466 case mfSCRIPT16:
2467 case mfSCRIPT17:
2468 case mfSCRIPT18:
2469 case mfSCRIPT19:
2470 case mfSCRIPT20:
2471 case mfPITHOLE:
2472 case mfPITFALLFLOOR:
2473 case mfLAVA:
2474 case mfICE:
2475 case mfICEDAMAGE:
2476 case mfDAMAGE1:
2477 case mfDAMAGE2:
2478 case mfDAMAGE4:
2479 case mfDAMAGE8:
2480 case mfDAMAGE16:
2481 case mfDAMAGE32:
2482 case mfFREEZEALL:
2483 case mfFREZEALLANSFFCS:
2484 case mfFREEZEFFCSOLY:
2485 case mfSCRITPTW1TRIG:
2486 case mfSCRITPTW2TRIG:
2487 case mfSCRITPTW3TRIG:
2488 case mfSCRITPTW4TRIG:
2489 case mfSCRITPTW5TRIG:
2490 case mfSCRITPTW6TRIG:
2491 case mfSCRITPTW7TRIG:
2492 case mfSCRITPTW8TRIG:
2493 case mfSCRITPTW9TRIG:
2494 case mfSCRITPTW10TRIG:
2495 case mfTROWEL:
2496 case mfTROWELNEXT:
2497 case mfTROWELSPECIALITEM:
2498 case mfSLASHPOT:
2499 case mfLIFTPOT:
2500 case mfLIFTORSLASH:
2501 case mfLIFTROCK:
2502 case mfLIFTROCKHEAVY:
2503 case mfDROPITEM:
2504 case mfSPECIALITEM:
2505 case mfDROPKEY:
2506 case mfDROPLKEY:
2507 case mfDROPCOMPASS:
2508 case mfDROPMAP:
2509 case mfDROPBOSSKEY:
2510 case mfSPAWNNPC:
2511 case mfSWITCHHOOK:
2512 case mfSIDEVIEWLADDER:
2513 case mfSIDEVIEWPLATFORM:
2514 case mfNOENEMYSPAWN:
2515 case mfENEMYALL:
2516 case mfNOMIRROR:
2517 case mfUNSAFEGROUND:
2518 case mf168:
2519 case mf169:
2520 case mf170:
2521 case mf171:
2522 case mf172:
2523 case mf173:
2524 case mf174:
2525 case mf175:
2526 case mf176:
2527 case mf177:
2528 case mf178:
2529 case mf179:
2530 case mf180:
2531 case mf181:
2532 case mf182:
2533 case mf183:
2534 case mf184:
2535 case mf185:
2536 case mf186:
2537 case mf187:
2538 case mf188:
2539 case mf189:
2540 case mf190:
2541 case mf191:
2542 case mf192:
2543 case mf193:
2544 case mf194:
2545 case mf195:
2546 case mf196:
2547 case mf197:
2548 case mf198:
2549 case mf199:
2550 case mf200:
2551 case mf201:
2552 case mf202:
2553 case mf203:
2554 case mf204:
2555 case mf205:
2556 case mf206:
2557 case mf207:
2558 case mf208:
2559 case mf209:
2560 case mf210:
2561 case mf211:
2562 case mf212:
2563 case mf213:
2564 case mf214:
2565 case mf215:
2566 case mf216:
2567 case mf217:
2568 case mf218:
2569 case mf219:
2570 case mf220:
2571 case mf221:
2572 case mf222:
2573 case mf223:
2574 case mf224:
2575 case mf225:
2576 case mf226:
2577 case mf227:
2578 case mf228:
2579 case mf229:
2580 case mf230:
2581 case mf231:
2582 case mf232:
2583 case mf233:
2584 case mf234:
2585 case mf235:
2586 case mf236:
2587 case mf237:
2588 case mf238:
2589 case mf239:
2590 case mf240:
2591 case mf241:
2592 case mf242:
2593 case mf243:
2594 case mf244:
2595 case mf245:
2596 case mf246:
2597 case mf247:
2598 case mf248:
2599 case mf249:
2600 case mf250:
2601 case mf251:
2602 case mf252:
2603 case mf253:
2604 case mf254:
2605 case mfEXTENDED:
2606 6894870 break;
2607
2608 case mfPUSHUD:
2609 case mfPUSHLR:
2610 case mfPUSH4:
2611 case mfPUSHU:
2612 case mfPUSHD:
2613 case mfPUSHL:
2614 case mfPUSHR:
2615 case mfPUSHUDNS:
2616 case mfPUSHLRNS:
2617 case mfPUSH4NS:
2618 case mfPUSHUNS:
2619 case mfPUSHDNS:
2620 case mfPUSHLNS:
2621 case mfPUSHRNS:
2622 case mfPUSHUDINS:
2623 case mfPUSHLRINS:
2624 case mfPUSH4INS:
2625 case mfPUSHUINS:
2626 case mfPUSHDINS:
2627 case mfPUSHLINS:
2628 case mfPUSHRINS:
2629
3/4
✓ Branch 0 taken 1939 times.
✓ Branch 1 taken 1319 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1939 times.
3258 if(!hints && ((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&16))
2630
2/6
✗ Branch 0 not taken.
✓ Branch 1 taken 1939 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1939 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
1939 || ((get_debug() && zc_getkey(KEY_N)) && (frame&16))))
2631 {
2632 if(!(itemsbuf[Hero.getLastLensID()].flags & item_flag2))putcombo(dest,x,y,tmpscr->undercombo,tmpscr->undercset);
2633 }
2634
2635
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3258 times.
3258 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
2636
3/6
✓ Branch 0 taken 2520 times.
✓ Branch 1 taken 738 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 738 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
3258 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
2637 {
2638
2/2
✓ Branch 0 taken 1488 times.
✓ Branch 1 taken 1032 times.
2520 if(hints)
2639 {
2640
3/3
✓ Branch 0 taken 72 times.
✓ Branch 1 taken 63 times.
✓ Branch 2 taken 897 times.
1032 switch(combobuf[tmpscr->data[i]].type)
2641 {
2642 case cPUSH_HEAVY:
2643 case cPUSH_HW:
2644 72 tempitem=getItemIDPower(itemsbuf,itype_bracelet,1);
2645 72 tempitemx=x, tempitemy=y;
2646
2647
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 72 times.
72 if(tempitem>-1)
2648 72 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
2649
2650 72 break;
2651
2652 case cPUSH_HEAVY2:
2653 case cPUSH_HW2:
2654 63 tempitem=getItemIDPower(itemsbuf,itype_bracelet,2);
2655 63 tempitemx=x, tempitemy=y;
2656
2657
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 63 times.
63 if(tempitem>-1)
2658 63 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
2659
2660 63 break;
2661 }
2662 1032 }
2663 2520 }
2664
2665 3258 break;
2666
2667 case mfWHISTLE:
2668
1/2
✓ Branch 0 taken 2418 times.
✗ Branch 1 not taken.
2418 if(hints)
2669 {
2670 tempitem=getItemID(itemsbuf,itype_whistle,1);
2671
2672 if(tempitem<0) break;
2673
2674 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
2675 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
2676 {
2677 tempitemx=x;
2678 tempitemy=y;
2679 }
2680
2681 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
2682 }
2683
2684 2418 break;
2685
2686 //Why is this here?
2687 case mfFAIRY:
2688 case mfMAGICFAIRY:
2689 case mfALLFAIRY:
2690 if(hints)
2691 {
2692 tempitem=getItemID(itemsbuf, itype_fairy,1);//iFairyMoving;
2693
2694 if(tempitem < 0) break;
2695
2696 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
2697 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
2698 {
2699 tempitemx=x;
2700 tempitemy=y;
2701 }
2702
2703 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
2704 }
2705
2706 break;
2707
2708 case mfANYFIRE:
2709
2/2
✓ Branch 0 taken 252 times.
✓ Branch 1 taken 252 times.
504 if(!hints)
2710 {
2711
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 252 times.
252 if(!(itemsbuf[Hero.getLastLensID()].flags & item_flag2))putcombo(dest,x,y,tmpscr->secretcombo[sBCANDLE],tmpscr->secretcset[sBCANDLE]);
2712 252 }
2713 else
2714 {
2715 252 tempitem=getItemID(itemsbuf,itype_candle,1);
2716
2717
1/2
✓ Branch 0 taken 252 times.
✗ Branch 1 not taken.
252 if(tempitem<0) break;
2718
2719
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 252 times.
252 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
2720
3/6
✓ Branch 0 taken 189 times.
✓ Branch 1 taken 63 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 63 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
252 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
2721 {
2722 189 tempitemx=x;
2723 189 tempitemy=y;
2724 189 }
2725
2726 252 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
2727 }
2728
2729 504 break;
2730
2731 case mfSTRONGFIRE:
2732 if(!hints)
2733 {
2734 if(!(itemsbuf[Hero.getLastLensID()].flags & item_flag2))putcombo(dest,x,y,tmpscr->secretcombo[sRCANDLE],tmpscr->secretcset[sRCANDLE]);
2735 }
2736 else
2737 {
2738 tempitem=getItemID(itemsbuf,itype_candle,2);
2739
2740 if(tempitem<0) break;
2741
2742 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
2743 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
2744 {
2745 tempitemx=x;
2746 tempitemy=y;
2747 }
2748
2749 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
2750 }
2751
2752 break;
2753
2754 case mfMAGICFIRE:
2755 if(!hints)
2756 {
2757 if(!(itemsbuf[Hero.getLastLensID()].flags & item_flag2))putcombo(dest,x,y,tmpscr->secretcombo[sWANDFIRE],tmpscr->secretcset[sWANDFIRE]);
2758 }
2759 else
2760 {
2761 tempitem=getItemID(itemsbuf,itype_wand,1);
2762
2763 if(tempitem<0) break;
2764
2765 tempweapon=wFire;
2766
2767 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
2768 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
2769 {
2770 tempitemx=x;
2771 tempitemy=y;
2772 }
2773 else
2774 {
2775 tempweaponx=x;
2776 tempweapony=y;
2777 }
2778
2779 putweapon(dest,tempweaponx,tempweapony,tempweapon, 0, up, lens_hint_weapon[tempweapon][0], lens_hint_weapon[tempweapon][1],-1);
2780 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
2781 }
2782
2783 break;
2784
2785 case mfDIVINEFIRE:
2786 if(!hints)
2787 {
2788 if(!(itemsbuf[Hero.getLastLensID()].flags & item_flag2))putcombo(dest,x,y,tmpscr->secretcombo[sDIVINEFIRE],tmpscr->secretcset[sDIVINEFIRE]);
2789 }
2790 else
2791 {
2792 tempitem=getItemID(itemsbuf,itype_divinefire,1);
2793
2794 if(tempitem<0) break;
2795
2796 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
2797 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
2798 {
2799 tempitemx=x;
2800 tempitemy=y;
2801 }
2802
2803 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
2804 }
2805
2806 break;
2807
2808 case mfARROW:
2809
2/2
✓ Branch 0 taken 82 times.
✓ Branch 1 taken 732 times.
814 if(!hints)
2810 {
2811
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 732 times.
732 if(!(itemsbuf[Hero.getLastLensID()].flags & item_flag2))putcombo(dest,x,y,tmpscr->secretcombo[sARROW],tmpscr->secretcset[sARROW]);
2812 732 }
2813 else
2814 {
2815 82 tempitem=getItemID(itemsbuf,itype_arrow,1);
2816
2817
1/2
✓ Branch 0 taken 82 times.
✗ Branch 1 not taken.
82 if(tempitem<0) break;
2818
2819
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 82 times.
82 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
2820
3/6
✓ Branch 0 taken 61 times.
✓ Branch 1 taken 21 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 21 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
82 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
2821 {
2822 61 tempitemx=x;
2823 61 tempitemy=y;
2824 61 }
2825
2826 82 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
2827 }
2828
2829 814 break;
2830
2831 case mfSARROW:
2832 if(!hints)
2833 {
2834 if(!(itemsbuf[Hero.getLastLensID()].flags & item_flag2))putcombo(dest,x,y,tmpscr->secretcombo[sSARROW],tmpscr->secretcset[sSARROW]);
2835 }
2836 else
2837 {
2838 tempitem=getItemID(itemsbuf,itype_arrow,2);
2839
2840 if(tempitem<0) break;
2841
2842 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
2843 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
2844 {
2845 tempitemx=x;
2846 tempitemy=y;
2847 }
2848
2849 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
2850 }
2851
2852 break;
2853
2854 case mfGARROW:
2855 if(!hints)
2856 {
2857 if(!(itemsbuf[Hero.getLastLensID()].flags & item_flag2))putcombo(dest,x,y,tmpscr->secretcombo[sGARROW],tmpscr->secretcset[sGARROW]);
2858 }
2859 else
2860 {
2861 tempitem=getItemID(itemsbuf,itype_arrow,3);
2862
2863 if(tempitem<0) break;
2864
2865 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
2866 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
2867 {
2868 tempitemx=x;
2869 tempitemy=y;
2870 }
2871
2872 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
2873 }
2874
2875 break;
2876
2877 case mfBOMB:
2878
2/2
✓ Branch 0 taken 17 times.
✓ Branch 1 taken 76 times.
93 if(!hints)
2879 {
2880
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 76 times.
76 if(!(itemsbuf[Hero.getLastLensID()].flags & item_flag2))putcombo(dest,x,y,tmpscr->secretcombo[sBOMB],tmpscr->secretcset[sBOMB]);
2881 76 }
2882 else
2883 {
2884 //tempitem=getItemID(itemsbuf,itype_bomb,1);
2885 17 tempweapon = wLitBomb;
2886
2887 //if (tempitem<0) break;
2888
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 17 times.
17 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
2889
3/6
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 5 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 5 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
17 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
2890 {
2891 12 tempweaponx=x;
2892 12 tempweapony=y;
2893 12 }
2894
2895 17 putweapon(dest,tempweaponx,tempweapony+lens_hint_weapon[tempweapon][4],tempweapon, 0, up, lens_hint_weapon[tempweapon][0], lens_hint_weapon[tempweapon][1],-1);
2896 }
2897
2898 93 break;
2899
2900 case mfSBOMB:
2901
2/2
✓ Branch 0 taken 48 times.
✓ Branch 1 taken 48 times.
96 if(!hints)
2902 {
2903
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 48 times.
48 if(!(itemsbuf[Hero.getLastLensID()].flags & item_flag2))putcombo(dest,x,y,tmpscr->secretcombo[sSBOMB],tmpscr->secretcset[sSBOMB]);
2904 48 }
2905 else
2906 {
2907 //tempitem=getItemID(itemsbuf,itype_sbomb,1);
2908 //if (tempitem<0) break;
2909 48 tempweapon = wLitSBomb;
2910
2911
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 48 times.
48 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
2912
3/6
✓ Branch 0 taken 36 times.
✓ Branch 1 taken 12 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 12 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
48 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
2913 {
2914 36 tempweaponx=x;
2915 36 tempweapony=y;
2916 36 }
2917
2918 48 putweapon(dest,tempweaponx,tempweapony+lens_hint_weapon[tempweapon][4],tempweapon, 0, up, lens_hint_weapon[tempweapon][0], lens_hint_weapon[tempweapon][1],-1);
2919 }
2920
2921 96 break;
2922
2923 case mfARMOS_SECRET:
2924
2/2
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 12 times.
24 if(!hints)
2925 {
2926
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 12 times.
12 if(!(itemsbuf[Hero.getLastLensID()].flags & item_flag2))putcombo(dest,x,y,tmpscr->secretcombo[sSTAIRS],tmpscr->secretcset[sSTAIRS]);
2927 12 }
2928 24 break;
2929
2930 case mfBRANG:
2931
2/2
✓ Branch 0 taken 5 times.
✓ Branch 1 taken 20 times.
25 if(!hints)
2932 {
2933
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 20 times.
20 if(!(itemsbuf[Hero.getLastLensID()].flags & item_flag2))putcombo(dest,x,y,tmpscr->secretcombo[sBRANG],tmpscr->secretcset[sBRANG]);
2934 20 }
2935 else
2936 {
2937 5 tempitem=getItemID(itemsbuf,itype_brang,1);
2938
2939
1/2
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
5 if(tempitem<0) break;
2940
2941
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 5 times.
5 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
2942
3/6
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
5 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
2943 {
2944 4 tempitemx=x;
2945 4 tempitemy=y;
2946 4 }
2947
2948 5 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
2949 }
2950
2951 25 break;
2952
2953 case mfMBRANG:
2954 if(!hints)
2955 {
2956 if(!(itemsbuf[Hero.getLastLensID()].flags & item_flag2))putcombo(dest,x,y,tmpscr->secretcombo[sMBRANG],tmpscr->secretcset[sMBRANG]);
2957 }
2958 else
2959 {
2960 tempitem=getItemID(itemsbuf,itype_brang,2);
2961
2962 if(tempitem<0) break;
2963
2964 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
2965 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
2966 {
2967 tempitemx=x;
2968 tempitemy=y;
2969 }
2970
2971 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
2972 }
2973
2974 break;
2975
2976 case mfFBRANG:
2977 if(!hints)
2978 {
2979 if(!(itemsbuf[Hero.getLastLensID()].flags & item_flag2))putcombo(dest,x,y,tmpscr->secretcombo[sFBRANG],tmpscr->secretcset[sFBRANG]);
2980 }
2981 else
2982 {
2983 tempitem=getItemID(itemsbuf,itype_brang,3);
2984
2985 if(tempitem<0) break;
2986
2987 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
2988 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
2989 {
2990 tempitemx=x;
2991 tempitemy=y;
2992 }
2993
2994 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
2995 }
2996
2997 break;
2998
2999 case mfWANDMAGIC:
3000
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 138 times.
138 if(!hints)
3001 {
3002
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 138 times.
138 if(!(itemsbuf[Hero.getLastLensID()].flags & item_flag2))putcombo(dest,x,y,tmpscr->secretcombo[sWANDMAGIC],tmpscr->secretcset[sWANDMAGIC]);
3003 138 }
3004 else
3005 {
3006 tempitem=getItemID(itemsbuf,itype_wand,1);
3007
3008 if(tempitem<0) break;
3009
3010 tempweapon=itemsbuf[tempitem].wpn3;
3011
3012 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3013 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3014 {
3015 tempitemx=x;
3016 tempitemy=y;
3017 }
3018 else
3019 {
3020 tempweaponx=x;
3021 tempweapony=y;
3022 --lens_hint_weapon[wMagic][4];
3023
3024 if(lens_hint_weapon[wMagic][4]<-8)
3025 {
3026 lens_hint_weapon[wMagic][4]=8;
3027 }
3028 }
3029
3030 putweapon(dest,tempweaponx,tempweapony+lens_hint_weapon[tempweapon][4],tempweapon, 0, up, lens_hint_weapon[tempweapon][0], lens_hint_weapon[tempweapon][1],-1);
3031 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
3032 }
3033
3034 138 break;
3035
3036 case mfREFMAGIC:
3037
1/2
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
16 if(!hints)
3038 {
3039 if(!(itemsbuf[Hero.getLastLensID()].flags & item_flag2))putcombo(dest,x,y,tmpscr->secretcombo[sREFMAGIC],tmpscr->secretcset[sREFMAGIC]);
3040 }
3041 else
3042 {
3043 16 tempitem=getItemID(itemsbuf,itype_shield,3);
3044
3045
1/2
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
16 if(tempitem<0) break;
3046
3047 16 tempweapon=ewMagic;
3048
3049
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 16 times.
16 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3050
3/6
✓ Branch 0 taken 13 times.
✓ Branch 1 taken 3 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 3 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
16 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3051 {
3052 13 tempitemx=x;
3053 13 tempitemy=y;
3054 13 }
3055 else
3056 {
3057 3 tempweaponx=x;
3058 3 tempweapony=y;
3059
3060
2/2
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 1 times.
3 if(lens_hint_weapon[ewMagic][2]==up)
3061 {
3062 1 --lens_hint_weapon[ewMagic][4];
3063 1 }
3064 else
3065 {
3066 2 ++lens_hint_weapon[ewMagic][4];
3067 }
3068
3069
1/2
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
3 if(lens_hint_weapon[ewMagic][4]>8)
3070 {
3071 lens_hint_weapon[ewMagic][2]=up;
3072 }
3073
3074
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 2 times.
3 if(lens_hint_weapon[ewMagic][4]<=0)
3075 {
3076 2 lens_hint_weapon[ewMagic][2]=down;
3077 2 }
3078 }
3079
3080 16 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
3081 16 putweapon(dest,tempweaponx,tempweapony+lens_hint_weapon[tempweapon][4],tempweapon, 0, lens_hint_weapon[ewMagic][2], lens_hint_weapon[tempweapon][0], lens_hint_weapon[tempweapon][1],-1);
3082 }
3083
3084 16 break;
3085
3086 case mfREFFIREBALL:
3087
1/2
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
16 if(!hints)
3088 {
3089 if(!(itemsbuf[Hero.getLastLensID()].flags & item_flag2))putcombo(dest,x,y,tmpscr->secretcombo[sREFFIREBALL],tmpscr->secretcset[sREFFIREBALL]);
3090 }
3091 else
3092 {
3093 16 tempitem=getItemID(itemsbuf,itype_shield,3);
3094
3095
1/2
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
16 if(tempitem<0) break;
3096
3097 16 tempweapon=ewFireball;
3098
3099
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 16 times.
16 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3100
3/6
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 4 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
16 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3101 {
3102 12 tempitemx=x;
3103 12 tempitemy=y;
3104 12 tempweaponx=x;
3105 12 tempweapony=y;
3106 12 ++lens_hint_weapon[ewFireball][3];
3107
3108
2/2
✓ Branch 0 taken 11 times.
✓ Branch 1 taken 1 times.
12 if(lens_hint_weapon[ewFireball][3]>8)
3109 {
3110 1 lens_hint_weapon[ewFireball][3]=-8;
3111 1 lens_hint_weapon[ewFireball][4]=8;
3112 1 }
3113
3114
2/2
✓ Branch 0 taken 8 times.
✓ Branch 1 taken 4 times.
12 if(lens_hint_weapon[ewFireball][3]>0)
3115 {
3116 8 ++lens_hint_weapon[ewFireball][4];
3117 8 }
3118 else
3119 {
3120 4 --lens_hint_weapon[ewFireball][4];
3121 }
3122 12 }
3123
3124 16 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
3125 16 putweapon(dest,tempweaponx+lens_hint_weapon[tempweapon][3],tempweapony+lens_hint_weapon[ewFireball][4],tempweapon, 0, up, lens_hint_weapon[tempweapon][0], lens_hint_weapon[tempweapon][1],-1);
3126 }
3127
3128 16 break;
3129
3130 case mfSWORD:
3131
1/2
✓ Branch 0 taken 7 times.
✗ Branch 1 not taken.
7 if(!hints)
3132 {
3133 if(!(itemsbuf[Hero.getLastLensID()].flags & item_flag2))putcombo(dest,x,y,tmpscr->secretcombo[sSWORD],tmpscr->secretcset[sSWORD]);
3134 }
3135 else
3136 {
3137 7 tempitem=getItemID(itemsbuf,itype_sword,1);
3138
3139
1/2
✓ Branch 0 taken 7 times.
✗ Branch 1 not taken.
7 if(tempitem<0) break;
3140
3141
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7 times.
7 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3142
3/6
✓ Branch 0 taken 5 times.
✓ Branch 1 taken 2 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 2 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
7 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3143 {
3144 5 tempitemx=x;
3145 5 tempitemy=y;
3146 5 }
3147
3148 7 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
3149 }
3150
3151 7 break;
3152
3153 case mfWSWORD:
3154 if(!hints)
3155 {
3156 if(!(itemsbuf[Hero.getLastLensID()].flags & item_flag2))putcombo(dest,x,y,tmpscr->secretcombo[sWSWORD],tmpscr->secretcset[sWSWORD]);
3157 }
3158 else
3159 {
3160 tempitem=getItemID(itemsbuf,itype_sword,2);
3161
3162 if(tempitem<0) break;
3163
3164 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3165 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3166 {
3167 tempitemx=x;
3168 tempitemy=y;
3169 }
3170
3171 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
3172 }
3173
3174 break;
3175
3176 case mfMSWORD:
3177 if(!hints)
3178 {
3179 if(!(itemsbuf[Hero.getLastLensID()].flags & item_flag2))putcombo(dest,x,y,tmpscr->secretcombo[sMSWORD],tmpscr->secretcset[sMSWORD]);
3180 }
3181 else
3182 {
3183 tempitem=getItemID(itemsbuf,itype_sword,3);
3184
3185 if(tempitem<0) break;
3186
3187 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3188 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3189 {
3190 tempitemx=x;
3191 tempitemy=y;
3192 }
3193
3194 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
3195 }
3196
3197 break;
3198
3199 case mfXSWORD:
3200 if(!hints)
3201 {
3202 if(!(itemsbuf[Hero.getLastLensID()].flags & item_flag2))putcombo(dest,x,y,tmpscr->secretcombo[sXSWORD],tmpscr->secretcset[sXSWORD]);
3203 }
3204 else
3205 {
3206 tempitem=getItemID(itemsbuf,itype_sword,4);
3207
3208 if(tempitem<0) break;
3209
3210 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3211 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3212 {
3213 tempitemx=x;
3214 tempitemy=y;
3215 }
3216
3217 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
3218 }
3219
3220 break;
3221
3222 case mfSWORDBEAM:
3223
1/2
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
16 if(!hints)
3224 {
3225 if(!(itemsbuf[Hero.getLastLensID()].flags & item_flag2))putcombo(dest,x,y,tmpscr->secretcombo[sSWORDBEAM],tmpscr->secretcset[sSWORDBEAM]);
3226 }
3227 else
3228 {
3229 16 tempitem=getItemID(itemsbuf,itype_sword,1);
3230
3231
1/2
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
16 if(tempitem<0) break;
3232
3233
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 16 times.
16 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3234
3/6
✓ Branch 0 taken 11 times.
✓ Branch 1 taken 5 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 5 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
16 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3235 {
3236 11 tempitemx=x;
3237 11 tempitemy=y;
3238 11 }
3239
3240 16 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 1);
3241 }
3242
3243 16 break;
3244
3245 case mfWSWORDBEAM:
3246 if(!hints)
3247 {
3248 if(!(itemsbuf[Hero.getLastLensID()].flags & item_flag2))putcombo(dest,x,y,tmpscr->secretcombo[sWSWORDBEAM],tmpscr->secretcset[sWSWORDBEAM]);
3249 }
3250 else
3251 {
3252 tempitem=getItemID(itemsbuf,itype_sword,2);
3253
3254 if(tempitem<0) break;
3255
3256 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3257 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3258 {
3259 tempitemx=x;
3260 tempitemy=y;
3261 }
3262
3263 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 2);
3264 }
3265
3266 break;
3267
3268 case mfMSWORDBEAM:
3269 if(!hints)
3270 {
3271 if(!(itemsbuf[Hero.getLastLensID()].flags & item_flag2))putcombo(dest,x,y,tmpscr->secretcombo[sMSWORDBEAM],tmpscr->secretcset[sMSWORDBEAM]);
3272 }
3273 else
3274 {
3275 tempitem=getItemID(itemsbuf,itype_sword,3);
3276
3277 if(tempitem<0) break;
3278
3279 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3280 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3281 {
3282 tempitemx=x;
3283 tempitemy=y;
3284 }
3285
3286 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 3);
3287 }
3288
3289 break;
3290
3291 case mfXSWORDBEAM:
3292 if(!hints)
3293 {
3294 if(!(itemsbuf[Hero.getLastLensID()].flags & item_flag2))putcombo(dest,x,y,tmpscr->secretcombo[sXSWORDBEAM],tmpscr->secretcset[sXSWORDBEAM]);
3295 }
3296 else
3297 {
3298 tempitem=getItemID(itemsbuf,itype_sword,4);
3299
3300 if(tempitem<0) break;
3301
3302 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3303 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3304 {
3305 tempitemx=x;
3306 tempitemy=y;
3307 }
3308
3309 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 4);
3310 }
3311
3312 break;
3313
3314 case mfHOOKSHOT:
3315
1/2
✓ Branch 0 taken 17 times.
✗ Branch 1 not taken.
17 if(!hints)
3316 {
3317 if(!(itemsbuf[Hero.getLastLensID()].flags & item_flag2))putcombo(dest,x,y,tmpscr->secretcombo[sHOOKSHOT],tmpscr->secretcset[sHOOKSHOT]);
3318 }
3319 else
3320 {
3321 17 tempitem=getItemID(itemsbuf,itype_hookshot,1);
3322
3323
1/2
✓ Branch 0 taken 17 times.
✗ Branch 1 not taken.
17 if(tempitem<0) break;
3324
3325
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 17 times.
17 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3326
3/6
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 5 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 5 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
17 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3327 {
3328 12 tempitemx=x;
3329 12 tempitemy=y;
3330 12 }
3331
3332 17 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
3333 }
3334
3335 17 break;
3336
3337 case mfWAND:
3338
1/2
✓ Branch 0 taken 35 times.
✗ Branch 1 not taken.
35 if(!hints)
3339 {
3340 if(!(itemsbuf[Hero.getLastLensID()].flags & item_flag2))putcombo(dest,x,y,tmpscr->secretcombo[sWAND],tmpscr->secretcset[sWAND]);
3341 }
3342 else
3343 {
3344 35 tempitem=getItemID(itemsbuf,itype_wand,1);
3345
3346
1/2
✓ Branch 0 taken 35 times.
✗ Branch 1 not taken.
35 if(tempitem<0) break;
3347
3348
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 35 times.
35 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3349
3/6
✓ Branch 0 taken 28 times.
✓ Branch 1 taken 7 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 7 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
35 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3350 {
3351 28 tempitemx=x;
3352 28 tempitemy=y;
3353 28 }
3354
3355 35 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
3356 }
3357
3358 35 break;
3359
3360 case mfHAMMER:
3361
1/2
✓ Branch 0 taken 17 times.
✗ Branch 1 not taken.
17 if(!hints)
3362 {
3363 if(!(itemsbuf[Hero.getLastLensID()].flags & item_flag2))putcombo(dest,x,y,tmpscr->secretcombo[sHAMMER],tmpscr->secretcset[sHAMMER]);
3364 }
3365 else
3366 {
3367 17 tempitem=getItemID(itemsbuf,itype_hammer,1);
3368
3369
1/2
✓ Branch 0 taken 17 times.
✗ Branch 1 not taken.
17 if(tempitem<0) break;
3370
3371
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 17 times.
17 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3372
3/6
✓ Branch 0 taken 13 times.
✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 4 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
17 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3373 {
3374 13 tempitemx=x;
3375 13 tempitemy=y;
3376 13 }
3377
3378 17 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
3379 }
3380
3381 17 break;
3382
3383 case mfARMOS_ITEM:
3384 case mfDIVE_ITEM:
3385
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 2602 times.
✓ Branch 2 taken 2602 times.
✗ Branch 3 not taken.
2602 if((!getmapflag() || (tmpscr->flags9&fBELOWRETURN)) && !(itemsbuf[Hero.getLastLensID()].flags & item_flag3))
3386 {
3387 2602 putitem2(dest,x,y,tmpscr->catchall, lens_hint_item[tmpscr->catchall][0], lens_hint_item[tmpscr->catchall][1], 0);
3388 2602 }
3389 2602 break;
3390
3391 case 16:
3392 case 17:
3393 case 18:
3394 case 19:
3395 case 20:
3396 case 21:
3397 case 22:
3398 case 23:
3399 case 24:
3400 case 25:
3401 case 26:
3402 case 27:
3403 case 28:
3404 case 29:
3405 case 30:
3406 case 31:
3407
2/2
✓ Branch 0 taken 1008 times.
✓ Branch 1 taken 107890 times.
108898 if(!hints)
3408
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 107890 times.
215780 if(!(itemsbuf[Hero.getLastLensID()].flags & item_flag2))
3409 107890 putcombo(dest,x,y,tmpscr->secretcombo[checkflag-16+4],tmpscr->secretcset[checkflag-16+4]);
3410
3411 108898 break;
3412 case mfSECRETSNEXT:
3413 if(!hints)
3414 if(!(itemsbuf[Hero.getLastLensID()].flags & item_flag2))
3415 putcombo(dest,x,y,tmpscr->data[i]+1,tmpscr->cset[i]);
3416
3417 break;
3418
3419 case mfSTRIKE:
3420
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 906 times.
906 if(!(itemsbuf[Hero.getLastLensID()].flags & item_flag2))
3421 {
3422 906 goto special;
3423 }
3424 else
3425 {
3426 break;
3427 }
3428
3429 28750 default: goto special;
3430
3431 special:
3432
8/8
✓ Branch 0 taken 14732 times.
✓ Branch 1 taken 14924 times.
✓ Branch 2 taken 528 times.
✓ Branch 3 taken 14204 times.
✓ Branch 4 taken 496 times.
✓ Branch 5 taken 32 times.
✓ Branch 6 taken 6108 times.
✓ Branch 7 taken 8128 times.
29656 if(layer && ((checkflag!=mfRAFT && checkflag!=mfRAFT_BRANCH&& checkflag!=mfRAFT_BOUNCE) ||(itemsbuf[Hero.getLastLensID()].flags & item_flag4)))
3433 {
3434
4/8
✗ Branch 0 not taken.
✓ Branch 1 taken 6604 times.
✓ Branch 2 taken 4954 times.
✓ Branch 3 taken 1650 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 1650 times.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
6604 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate)) || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3435 {
3436 4954 rectfill(dest,x,y,x+15,y+15,WHITE);
3437 4954 }
3438 6604 }
3439
3440 29656 break;
3441 }
3442 7043520 }
3443 3521760 }
3444
3445
2/2
✓ Branch 0 taken 10005 times.
✓ Branch 1 taken 10005 times.
20010 if(layer)
3446 {
3447
2/2
✓ Branch 0 taken 9646 times.
✓ Branch 1 taken 359 times.
10005 if(tmpscr->door[0]==dWALK)
3448 359 rectfill(dest, 120, 16+playing_field_offset, 135, 31+playing_field_offset, WHITE);
3449
3450
2/2
✓ Branch 0 taken 9582 times.
✓ Branch 1 taken 423 times.
10005 if(tmpscr->door[1]==dWALK)
3451 423 rectfill(dest, 120, 144+playing_field_offset, 135, 159+playing_field_offset, WHITE);
3452
3453
2/2
✓ Branch 0 taken 9423 times.
✓ Branch 1 taken 582 times.
10005 if(tmpscr->door[2]==dWALK)
3454 582 rectfill(dest, 16, 80+playing_field_offset, 31, 95+playing_field_offset, WHITE);
3455
3456
2/2
✓ Branch 0 taken 9381 times.
✓ Branch 1 taken 624 times.
10005 if(tmpscr->door[3]==dWALK)
3457 624 rectfill(dest, 224, 80+playing_field_offset, 239, 95+playing_field_offset, WHITE);
3458
3459
2/2
✓ Branch 0 taken 9962 times.
✓ Branch 1 taken 43 times.
10005 if(tmpscr->door[0]==dBOMB)
3460 {
3461 43 showbombeddoor(dest, 0);
3462 43 }
3463
3464
2/2
✓ Branch 0 taken 9966 times.
✓ Branch 1 taken 39 times.
10005 if(tmpscr->door[1]==dBOMB)
3465 {
3466 39 showbombeddoor(dest, 1);
3467 39 }
3468
3469
2/2
✓ Branch 0 taken 9999 times.
✓ Branch 1 taken 6 times.
10005 if(tmpscr->door[2]==dBOMB)
3470 {
3471 6 showbombeddoor(dest, 2);
3472 6 }
3473
3474
2/2
✓ Branch 0 taken 9968 times.
✓ Branch 1 taken 37 times.
10005 if(tmpscr->door[3]==dBOMB)
3475 {
3476 37 showbombeddoor(dest, 3);
3477 37 }
3478 10005 }
3479
3480
2/2
✓ Branch 0 taken 17976 times.
✓ Branch 1 taken 2034 times.
20010 if(tmpscr->stairx + tmpscr->stairy)
3481 {
3482
2/2
✓ Branch 0 taken 911 times.
✓ Branch 1 taken 1123 times.
2034 if(!hints)
3483 {
3484
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1123 times.
1123 if(!(itemsbuf[Hero.getLastLensID()].flags & item_flag2))
3485 1123 putcombo(dest,tmpscr->stairx,tmpscr->stairy+playing_field_offset,tmpscr->secretcombo[sSTAIRS],tmpscr->secretcset[sSTAIRS]);
3486 1123 }
3487 else
3488 {
3489
2/2
✓ Branch 0 taken 863 times.
✓ Branch 1 taken 48 times.
911 if(tmpscr->flags&fWHISTLE)
3490 {
3491 48 tempitem=getItemID(itemsbuf,itype_whistle,1);
3492 48 int32_t tempitemx=-16;
3493 48 int32_t tempitemy=-16;
3494
3495
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 48 times.
48 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&(blink_rate/4)))
3496
3/6
✓ Branch 0 taken 24 times.
✓ Branch 1 taken 24 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 24 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
48 || ((get_debug() && zc_getkey(KEY_N)) && (frame&(blink_rate/4))))
3497 {
3498 24 tempitemx=tmpscr->stairx;
3499 24 tempitemy=tmpscr->stairy+playing_field_offset;
3500 24 }
3501
3502 48 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
3503 48 }
3504 }
3505 2034 }
3506 }
3507 20010 }
3508
3509 BITMAP *lens_scr_d; // The "d" is for "destructible"!
3510
3511 9666 void draw_lens_over()
3512 {
3513 // Oh, what the heck.
3514 static BITMAP *lens_scr = NULL;
3515 static int32_t last_width = -1;
3516 9666 int32_t width = itemsbuf[current_item_id(itype_lens,true)].misc1;
3517
3518 // Only redraw the circle if the size has changed
3519
2/2
✓ Branch 0 taken 9647 times.
✓ Branch 1 taken 19 times.
9666 if(width != last_width)
3520 {
3521
2/2
✓ Branch 0 taken 17 times.
✓ Branch 1 taken 2 times.
19 if(lens_scr == NULL)
3522 {
3523 17 lens_scr = create_bitmap_ex(8,2*288,2*(240-playing_field_offset));
3524 17 }
3525
3526 19 clear_to_color(lens_scr, BLACK);
3527 19 circlefill(lens_scr, 288, 240-playing_field_offset, width, 0);
3528 19 circle(lens_scr, 288, 240-playing_field_offset, width+2, 0);
3529 19 circle(lens_scr, 288, 240-playing_field_offset, width+5, 0);
3530 19 last_width=width;
3531 19 }
3532
3533 9666 masked_blit(lens_scr, framebuf, 288-(HeroX()+8), 240-playing_field_offset-(HeroY()+8), 0, playing_field_offset, 256, 168);
3534 9666 do_primitives(framebuf, SPLAYER_LENS_OVER, tmpscr, 0, playing_field_offset);
3535 9666 }
3536
3537 //----------------------------------------------------------------
3538
3539 31797 void draw_wavy(BITMAP *source, BITMAP *target, int32_t amplitude, bool interpol)
3540 {
3541 //recreating a big bitmap every frame is highly sluggish.
3542
4/6
✓ Branch 0 taken 5 times.
✓ Branch 1 taken 31792 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 5 times.
✓ Branch 4 taken 5 times.
✗ Branch 5 not taken.
31797 static BITMAP *wavebuf = create_bitmap_ex(8,288,240-original_playing_field_offset);
3543 31797 clear_to_color(wavebuf, BLACK);
3544 31797 blit(source,wavebuf,0,original_playing_field_offset,16,0,256,224-original_playing_field_offset);
3545
3546 int32_t ofs;
3547
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 31797 times.
31797 amplitude = zc_min(2048,amplitude); // some arbitrary limit to prevent crashing
3548
4/6
✓ Branch 0 taken 31797 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 31797 times.
✓ Branch 4 taken 494 times.
✓ Branch 5 taken 31303 times.
31797 if(flash_reduction_enabled() && !get_qr(qr_WAVY_NO_EPILEPSY)) amplitude = zc_min(16,amplitude);
3549 31797 int32_t amp2=168;
3550
2/4
✓ Branch 0 taken 31797 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 31797 times.
31797 if(flash_reduction_enabled() && !get_qr(qr_WAVY_NO_EPILEPSY_2)) amp2*=2;
3551 31797 int32_t i=frame%amp2;
3552
3553
2/2
✓ Branch 0 taken 5341896 times.
✓ Branch 1 taken 31797 times.
5373693 for(int32_t j=0; j<168; j++)
3554 {
3555
3/4
✓ Branch 0 taken 2670948 times.
✓ Branch 1 taken 2670948 times.
✓ Branch 2 taken 2670948 times.
✗ Branch 3 not taken.
5341896 if(j&1 && interpol)
3556 {
3557 // Add 288*2048 to ensure it's never negative. It'll get modded out.
3558 ofs=288*2048+int32_t(zc::math::Sin((double(i+j)*2*PI/amp2))*amplitude);
3559 }
3560 else
3561 {
3562 5341896 ofs=288*2048-int32_t(zc::math::Sin((double(i+j)*2*PI/amp2))*amplitude);
3563 }
3564
3565
1/2
✓ Branch 0 taken 5341896 times.
✗ Branch 1 not taken.
5341896 if(ofs)
3566 {
3567
2/2
✓ Branch 0 taken 1367525376 times.
✓ Branch 1 taken 5341896 times.
1372867272 for(int32_t k=0; k<256; k++)
3568 {
3569 1367525376 target->line[j+original_playing_field_offset][k]=wavebuf->line[j][(k+ofs+16)%288];
3570 1367525376 }
3571 5341896 }
3572 5341896 }
3573 31797 }
3574
3575 28224 void draw_fuzzy(int32_t fuzz)
3576 // draws from right half of scrollbuf to framebuf
3577 {
3578 int32_t firstx, firsty, xstep, ystep, i, y, dx, dy;
3579 byte *start, *si, *di;
3580
3581
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 28224 times.
28224 if(fuzz<1)
3582 fuzz = 1;
3583
3584 28224 xstep = 128%fuzz;
3585
3586
2/2
✓ Branch 0 taken 5880 times.
✓ Branch 1 taken 22344 times.
28224 if(xstep > 0)
3587 22344 xstep = fuzz-xstep;
3588
3589 28224 ystep = 112%fuzz;
3590
3591
2/2
✓ Branch 0 taken 8232 times.
✓ Branch 1 taken 19992 times.
28224 if(ystep > 0)
3592 19992 ystep = fuzz-ystep;
3593
3594 28224 firsty = 1;
3595
3596
2/2
✓ Branch 0 taken 28224 times.
✓ Branch 1 taken 1018416 times.
1046640 for(y=0; y<224;)
3597 {
3598 1018416 start = &(scrollbuf->line[y][256]);
3599
3600
4/4
✓ Branch 0 taken 1004304 times.
✓ Branch 1 taken 6336288 times.
✓ Branch 2 taken 6322176 times.
✓ Branch 3 taken 1018416 times.
7340592 for(dy=0; dy<ystep && dy+y<224; dy++)
3601 {
3602 6322176 si = start;
3603 6322176 di = &(framebuf->line[y+dy][0]);
3604 6322176 i = xstep;
3605 6322176 firstx = 1;
3606
3607
2/2
✓ Branch 0 taken 1618477056 times.
✓ Branch 1 taken 6322176 times.
1624799232 for(dx=0; dx<256; dx++)
3608 {
3609 1618477056 *(di++) = *si;
3610
3611
2/2
✓ Branch 0 taken 1363746048 times.
✓ Branch 1 taken 254731008 times.
1618477056 if(++i >= fuzz)
3612 {
3613
2/2
✓ Branch 0 taken 248408832 times.
✓ Branch 1 taken 6322176 times.
254731008 if(!firstx)
3614 248408832 si += fuzz;
3615 else
3616 {
3617 6322176 si += fuzz-xstep;
3618 6322176 firstx = 0;
3619 }
3620
3621 254731008 i = 0;
3622 254731008 }
3623 1618477056 }
3624 6322176 }
3625
3626
2/2
✓ Branch 0 taken 990192 times.
✓ Branch 1 taken 28224 times.
1018416 if(!firsty)
3627 990192 y += fuzz;
3628 else
3629 {
3630 28224 y += ystep;
3631 28224 ystep = fuzz;
3632 28224 firsty = 0;
3633 }
3634 }
3635 28224 }
3636
3637 18319686 void updatescr(bool allowwavy)
3638 {
3639
4/6
✓ Branch 0 taken 246 times.
✓ Branch 1 taken 18319440 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 246 times.
✓ Branch 4 taken 246 times.
✗ Branch 5 not taken.
18319686 static BITMAP *wavybuf = create_bitmap_ex(8,256,224);
3640
4/6
✓ Branch 0 taken 246 times.
✓ Branch 1 taken 18319440 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 246 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 246 times.
18319686 static BITMAP *panorama = create_bitmap_ex(8,256,224);
3641
3642
2/2
✓ Branch 0 taken 18292381 times.
✓ Branch 1 taken 27305 times.
18319686 if(toogam)
3643 {
3644 27305 textout_ex(framebuf,font,"no walls",8,216,1,-1);
3645 27305 }
3646
3647
1/2
✓ Branch 0 taken 18319686 times.
✗ Branch 1 not taken.
18319686 if(Showpal)
3648 dump_pal(framebuf);
3649
3650
2/2
✓ Branch 0 taken 17806540 times.
✓ Branch 1 taken 513146 times.
18319686 if(!Playing)
3651 513146 black_opening_count=0;
3652
3653
2/2
✓ Branch 0 taken 18156915 times.
✓ Branch 1 taken 162771 times.
18319686 if(black_opening_count<0) //shape is opening up
3654 {
3655 162771 black_opening(framebuf,black_opening_x,black_opening_y,(66+black_opening_count),66);
3656
3657
2/4
✓ Branch 0 taken 162771 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 162771 times.
162771 if(Advance||(!Paused))
3658 {
3659 162771 ++black_opening_count;
3660 162771 }
3661 162771 }
3662
2/2
✓ Branch 0 taken 18108933 times.
✓ Branch 1 taken 47982 times.
18156915 else if(black_opening_count>0) //shape is closing
3663 {
3664 47982 black_opening(framebuf,black_opening_x,black_opening_y,black_opening_count,66);
3665
3666
2/4
✓ Branch 0 taken 47982 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 47982 times.
47982 if(Advance||(!Paused))
3667 {
3668 47982 --black_opening_count;
3669 47982 }
3670 47982 }
3671
3672
3/4
✓ Branch 0 taken 18112126 times.
✓ Branch 1 taken 207560 times.
✓ Branch 2 taken 18112126 times.
✗ Branch 3 not taken.
18319686 if(black_opening_count==0&&black_opening_shape==bosFADEBLACK)
3673 {
3674 black_opening_shape = bosCIRCLE;
3675 memcpy(RAMpal, tempblackpal, PAL_SIZE*sizeof(RGB));
3676 refreshTints();
3677 refreshpal=true;
3678 }
3679
3680
2/2
✓ Branch 0 taken 17690872 times.
✓ Branch 1 taken 628814 times.
18319686 if(refreshpal)
3681 {
3682 628814 refreshpal=false;
3683 628814 RAMpal[253] = _RGB(0,0,0);
3684 628814 RAMpal[254] = _RGB(255,255,255);
3685 628814 hw_palette = &RAMpal;
3686 628814 update_hw_pal = true;
3687
3688 // Creating rgb_table and trans_table is pretty expensive, so try not to redo the same work
3689 // within a short period of time by using a cache.
3690 typedef std::array<uint32_t, PAL_SIZE> pal_table_cache_key;
3691 struct pal_table_cache_entry {
3692 RGB_MAP rgb_table;
3693 COLOR_MAP trans_table;
3694 };
3695
3/4
✓ Branch 0 taken 246 times.
✓ Branch 1 taken 628568 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 246 times.
628814 static std::map<pal_table_cache_key, pal_table_cache_entry> pal_table_cache;
3696
3697 static constexpr int pal_table_cache_max_memory_mb = 10;
3698 static constexpr int pal_table_cache_max_size = pal_table_cache_max_memory_mb / ((double)sizeof(pal_table_cache_entry) / 1024 / 1024);
3699
2/2
✓ Branch 0 taken 628649 times.
✓ Branch 1 taken 165 times.
628814 if (pal_table_cache.size() > pal_table_cache_max_size)
3700 165 pal_table_cache.clear();
3701
3702 pal_table_cache_key key;
3703
2/2
✓ Branch 0 taken 160976384 times.
✓ Branch 1 taken 628814 times.
161605198 for (int i = 0; i < PAL_SIZE; i++)
3704 160976384 key[i] = RAMpal[i].r + (RAMpal[i].g << 8) + (RAMpal[i].b << 16);
3705 628814 auto cache_it = pal_table_cache.find(key);
3706
2/2
✓ Branch 0 taken 24956 times.
✓ Branch 1 taken 603858 times.
628814 if (cache_it == pal_table_cache.end())
3707 {
3708 24956 create_rgb_table(&rgb_table, RAMpal, NULL);
3709 24956 create_zc_trans_table(&trans_table, RAMpal, 128, 128, 128);
3710 24956 pal_table_cache[key] = {rgb_table, trans_table};
3711 24956 trans_table2 = trans_table;
3712 24956 }
3713 else
3714 {
3715 603858 rgb_table = cache_it->second.rgb_table;
3716 603858 trans_table = cache_it->second.trans_table;
3717 603858 trans_table2 = cache_it->second.trans_table;
3718 }
3719
3720
2/2
✓ Branch 0 taken 160976384 times.
✓ Branch 1 taken 628814 times.
161605198 for(int32_t q=0; q<PAL_SIZE; q++)
3721 {
3722 160976384 trans_table2.data[0][q] = q;
3723 160976384 trans_table2.data[q][q] = q;
3724 160976384 }
3725 628814 }
3726
3727 18319686 bool clearwavy = (wavy <= 0);
3728
3729
2/2
✓ Branch 0 taken 8341 times.
✓ Branch 1 taken 18311345 times.
18319686 if(wavy <= 0)
3730 {
3731 // So far one thing can alter wavy apart from scripts: Wavy DMaps.
3732 18311345 wavy = (DMaps[currdmap].flags&dmfWAVY ? 4 : 0);
3733 18311345 }
3734
3735 18319686 blit(framebuf, wavybuf, 0, 0, 0, 0, 256, 224);
3736
3737
6/6
✓ Branch 0 taken 32047 times.
✓ Branch 1 taken 18287639 times.
✓ Branch 2 taken 31925 times.
✓ Branch 3 taken 122 times.
✓ Branch 4 taken 128 times.
✓ Branch 5 taken 31797 times.
18319686 if(wavy && Playing && allowwavy)
3738 {
3739 31797 draw_wavy(framebuf, wavybuf, wavy,false);
3740 31797 }
3741
3742
2/2
✓ Branch 0 taken 18311345 times.
✓ Branch 1 taken 8341 times.
18319686 if(clearwavy)
3743 18311345 wavy = 0; // Wavy was set by a DMap flag. Clear it.
3744
2/4
✓ Branch 0 taken 8341 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 8341 times.
8341 else if(Playing && !Paused)
3745 8341 wavy--; // Wavy was set by a script. Decrement it.
3746
3747
5/6
✓ Branch 0 taken 17806540 times.
✓ Branch 1 taken 513146 times.
✓ Branch 2 taken 672020 times.
✓ Branch 3 taken 17134520 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 672020 times.
18319686 if(Playing && msgpos && !screenscrolling)
3748 {
3749
1/2
✓ Branch 0 taken 672020 times.
✗ Branch 1 not taken.
672020 if(!(msg_bg_display_buf->clip))
3750 672020 blit_msgstr_bg(framebuf,0,0,0,playing_field_offset,256,168);
3751
1/2
✓ Branch 0 taken 672020 times.
✗ Branch 1 not taken.
672020 if(!(msg_portrait_display_buf->clip))
3752 672020 blit_msgstr_prt(framebuf,0,0,0,playing_field_offset,256,168);
3753
1/2
✓ Branch 0 taken 672020 times.
✗ Branch 1 not taken.
672020 if(!(msg_txt_display_buf->clip))
3754 672020 blit_msgstr_fg(framebuf,0,0,0,playing_field_offset,256,168);
3755 672020 }
3756
3757
2/2
✓ Branch 0 taken 18129501 times.
✓ Branch 1 taken 190185 times.
18319686 bool nosubscr = (tmpscr->flags3&fNOSUBSCR && !(tmpscr->flags3&fNOSUBSCROFFSET));
3758
3759
2/2
✓ Branch 0 taken 18134774 times.
✓ Branch 1 taken 184912 times.
18319686 if(nosubscr)
3760 {
3761 184912 rectfill(panorama,0,0,255,passive_subscreen_height/2,0);
3762 184912 rectfill(panorama,0,168+passive_subscreen_height/2,255,168+passive_subscreen_height-1,0);
3763 184912 blit(wavybuf,panorama,0,playing_field_offset,0,passive_subscreen_height/2,256,224-passive_subscreen_height);
3764 184912 }
3765
3766 //TODO: Optimize blit 'overcalls' -Gleeok
3767
2/2
✓ Branch 0 taken 184912 times.
✓ Branch 1 taken 18134774 times.
18319686 BITMAP *source = nosubscr ? panorama : wavybuf;
3768 18319686 blit(source,framebuf,0,0,0,0,256,224);
3769
3770 18319686 update_hw_screen();
3771 18319686 }
3772
3773 //----------------------------------------------------------------
3774
3775 static PALETTE syspal;
3776 int32_t onGUISnapshot()
3777 {
3778 char buf[200];
3779 int32_t num=0;
3780 do
3781 {
3782 sprintf(buf, "%szc_screen%05d.%s", get_snap_str(), ++num, snapshotformat_str[SnapshotFormat][1]);
3783 }
3784 while(num<99999 && exists(buf));
3785
3786 if (!al_save_bitmap(buf, al_get_backbuffer(all_get_display())))
3787 InfoDialog("Error", "Failed to save snapshot").show();
3788
3789 return D_O_K;
3790 }
3791
3792 int32_t onNonGUISnapshot()
3793 {
3794 PALETTE temppal;
3795 get_palette(temppal);
3796 bool realpal=(zc_getkey(KEY_ZC_LCONTROL, true) || zc_getkey(KEY_ZC_RCONTROL, true));
3797
3798 char buf[200];
3799 int32_t num=0;
3800
3801 do
3802 {
3803 sprintf(buf, "%szc_screen%05d.%s", get_snap_str(), ++num, snapshotformat_str[SnapshotFormat][1]);
3804 }
3805 while(num<99999 && exists(buf));
3806
3807 if ((tmpscr->flags3&fNOSUBSCR && !(tmpscr->flags3&fNOSUBSCROFFSET)) && !(key[KEY_ALT]))
3808 {
3809 BITMAP *b = create_bitmap_ex(8,256,168);
3810 clear_to_color(b,0);
3811 blit(framebuf,b,0,passive_subscreen_height/2,0,0,256,168);
3812 alleg4_save_bitmap(b, SnapshotScale, buf, realpal ? temppal : RAMpal);
3813 destroy_bitmap(b);
3814 }
3815 else
3816 {
3817 alleg4_save_bitmap(framebuf, SnapshotScale, buf, realpal?temppal:RAMpal);
3818 }
3819
3820 return D_O_K;
3821 }
3822
3823 int32_t onSnapshot()
3824 {
3825 if(zc_getkey(KEY_LSHIFT, true)||zc_getkey(KEY_RSHIFT, true))
3826 {
3827 onGUISnapshot();
3828 }
3829 else
3830 {
3831 onNonGUISnapshot();
3832 }
3833
3834 return D_O_K;
3835 }
3836
3837 int32_t onSaveMapPic()
3838 {
3839 int32_t mapres2 = 0;
3840 char buf[200];
3841 int32_t num=0;
3842 mapscr tmpscr_b[2];
3843 mapscr tmpscr_c[6];
3844 BITMAP* _screen_draw_buffer = NULL;
3845 _screen_draw_buffer = create_bitmap_ex(8,256,224);
3846 set_clip_state(_screen_draw_buffer,1);
3847
3848 for(int32_t i=0; i<6; ++i)
3849 {
3850 tmpscr_c[i] = tmpscr2[i];
3851 tmpscr2[i].zero_memory();
3852
3853 if(i>=2)
3854 {
3855 continue;
3856 }
3857
3858 tmpscr_b[i] = tmpscr[i];
3859 tmpscr[i].zero_memory();
3860 }
3861
3862 do
3863 {
3864 sprintf(buf, "%szc_screen%05d.png", get_snap_str(), ++num);
3865 }
3866 while(num<99999 && exists(buf));
3867
3868 BITMAP* mappic = NULL;
3869
3870
3871 bool done=false, redraw=true;
3872
3873 mappic = create_bitmap_ex(8,(256*16)>>mapres,(176*8)>>mapres);
3874
3875 if(!mappic)
3876 {
3877 enter_sys_pal();
3878 jwin_alert("View Map","Not enough memory.",NULL,NULL,"OK",NULL,13,27,get_zc_font(font_lfont));
3879 exit_sys_pal();
3880 return D_O_K;;
3881 }
3882
3883 // draw the map
3884 set_clip_rect(_screen_draw_buffer, 0, 0, _screen_draw_buffer->w, _screen_draw_buffer->h);
3885
3886 for(int32_t y=0; y<8; y++)
3887 {
3888 for(int32_t x=0; x<16; x++)
3889 {
3890 if(!displayOnMap(x, y))
3891 {
3892 rectfill(_screen_draw_buffer, 0, 0, 255, 223, WHITE);
3893 }
3894 else
3895 {
3896 int32_t s = (y<<4) + x;
3897 loadscr2(1,s,-1);
3898
3899 for(int32_t i=0; i<6; i++)
3900 {
3901 if(tmpscr[1].layermap[i]<=0)
3902 continue;
3903
3904 tmpscr2[i]=TheMaps[(tmpscr[1].layermap[i]-1)*MAPSCRS+tmpscr[1].layerscreen[i]];
3905 }
3906
3907 if(XOR((tmpscr+1)->flags7&fLAYER2BG, DMaps[currdmap].flags&dmfLAYER2BG)) do_layer(_screen_draw_buffer, 0, 2, tmpscr+1, -256, playing_field_offset, 2);
3908
3909 if(XOR((tmpscr+1)->flags7&fLAYER3BG, DMaps[currdmap].flags&dmfLAYER3BG)) do_layer(_screen_draw_buffer, 0, 3, tmpscr+1, -256, playing_field_offset, 2);
3910
3911 if(lenscheck(tmpscr+1,0)) putscr(_screen_draw_buffer,256,0,tmpscr+1);
3912 do_layer(_screen_draw_buffer, 0, 1, tmpscr+1, -256, playing_field_offset, 2);
3913
3914 if(!XOR((tmpscr+1)->flags7&fLAYER2BG, DMaps[currdmap].flags&dmfLAYER2BG)) do_layer(_screen_draw_buffer, 0, 2, tmpscr+1, -256, playing_field_offset, 2);
3915
3916 putscrdoors(_screen_draw_buffer,256,0,tmpscr+1);
3917 if(get_qr(qr_PUSHBLOCK_SPRITE_LAYER))
3918 {
3919 do_layer(_screen_draw_buffer, -2, 0, tmpscr+1, -256, playing_field_offset, 2);
3920 if(get_qr(qr_PUSHBLOCK_LAYER_1_2))
3921 {
3922 do_layer(_screen_draw_buffer, -2, 1, tmpscr+1, -256, playing_field_offset, 2);
3923 do_layer(_screen_draw_buffer, -2, 2, tmpscr+1, -256, playing_field_offset, 2);
3924 }
3925 }
3926 do_layer(_screen_draw_buffer, -3, 0, tmpscr+1, -256, playing_field_offset, 2); // Freeform combos!
3927
3928 if(!XOR((tmpscr+1)->flags7&fLAYER3BG, DMaps[currdmap].flags&dmfLAYER3BG)) do_layer(_screen_draw_buffer, 0, 3, tmpscr+1, -256, playing_field_offset, 2);
3929
3930 do_layer(_screen_draw_buffer, 0, 4, tmpscr+1, -256, playing_field_offset, 2);
3931 do_layer(_screen_draw_buffer, -1, 0, tmpscr+1, -256, playing_field_offset, 2);
3932 if(get_qr(qr_OVERHEAD_COMBOS_L1_L2))
3933 {
3934 do_layer(_screen_draw_buffer, -1, 1, tmpscr+1, -256, playing_field_offset, 2);
3935 do_layer(_screen_draw_buffer, -1, 2, tmpscr+1, -256, playing_field_offset, 2);
3936 }
3937 do_layer(_screen_draw_buffer, 0, 5, tmpscr+1, -256, playing_field_offset, 2);
3938 do_layer(_screen_draw_buffer, 0, 6, tmpscr+1, -256, playing_field_offset, 2);
3939
3940 }
3941
3942 stretch_blit(_screen_draw_buffer, mappic, 256, 0, 256, 176, x<<(8-mapres), (y*176)>>mapres, 256>>mapres, 176>>mapres);
3943 }
3944 }
3945
3946 for(int32_t i=0; i<6; ++i)
3947 {
3948 tmpscr2[i]=tmpscr_c[i];
3949
3950 if(i>=2)
3951 {
3952 continue;
3953 }
3954
3955 tmpscr[i]=tmpscr_b[i];
3956 }
3957
3958 save_bitmap(buf,mappic,RAMpal);
3959 destroy_bitmap(mappic);
3960 destroy_bitmap(_screen_draw_buffer);
3961 return D_O_K;
3962 }
3963
3964 55 void f_Quit(int32_t type)
3965 {
3966
2/4
✓ Branch 0 taken 55 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 55 times.
✗ Branch 3 not taken.
55 if(type==qQUIT && !Playing)
3967 return;
3968
3969 55 bool from_menu = is_sys_pal;
3970
3971
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 55 times.
55 if(!from_menu)
3972 {
3973 55 music_pause();
3974 55 pause_all_sfx();
3975 55 sys_mouse();
3976 55 }
3977 55 enter_sys_pal();
3978 55 clear_keybuf();
3979
3980
2/2
✓ Branch 0 taken 42 times.
✓ Branch 1 taken 13 times.
55 if (replay_version_check(0, 10))
3981 13 replay_poll();
3982
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 55 times.
55 if (replay_is_replaying())
3983 55 replay_peek_quit();
3984
3985
1/2
✓ Branch 0 taken 55 times.
✗ Branch 1 not taken.
55 if (!replay_is_replaying())
3986 switch(type)
3987 {
3988 case qQUIT:
3989 onQuit();
3990 break;
3991
3992 case qRESET:
3993 onReset();
3994 break;
3995
3996 case qEXIT:
3997 onExit();
3998 break;
3999 }
4000
4001
1/2
✓ Branch 0 taken 55 times.
✗ Branch 1 not taken.
55 if(Quit)
4002 {
4003 55 kill_sfx();
4004 55 music_stop();
4005 55 exit_sys_pal();
4006 55 update_hw_screen();
4007 55 }
4008 else
4009 {
4010 exit_sys_pal();
4011 if(!from_menu)
4012 {
4013 music_resume();
4014 resume_all_sfx();
4015 }
4016 }
4017
4018
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 55 times.
55 if(!from_menu)
4019 55 game_mouse();
4020 55 eat_buttons();
4021
4022 55 zc_readrawkey(KEY_ESC);
4023
4024 55 zc_readrawkey(KEY_ENTER);
4025 55 }
4026
4027 //----------------------------------------------------------------
4028
4029 int32_t onNoWalls()
4030 {
4031 cheats_enqueue(Cheat::Walls);
4032 return D_O_K;
4033 }
4034
4035 int32_t onIgnoreSideview()
4036 {
4037 cheats_enqueue(Cheat::IgnoreSideView);
4038 return D_O_K;
4039 }
4040
4041 18318343 int32_t input_idle(bool checkmouse)
4042 {
4043 static int32_t mx, my, mz, mb;
4044
4045
4/6
✓ Branch 0 taken 18318343 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 4911060 times.
✓ Branch 3 taken 13407283 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 4911060 times.
23229403 if(keypressed() || zc_key_pressed() ||
4046
4/8
✓ Branch 0 taken 4911060 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 4911060 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 4911060 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 4911060 times.
✗ Branch 7 not taken.
4911060 (checkmouse && (mx != mouse_x || my != mouse_y || mz != mouse_z || mb != mouse_b)))
4047 {
4048 13407283 idle_count = 0;
4049
4050
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 13407283 times.
13407283 if(active_count < MAX_ACTIVE)
4051 {
4052 13407283 ++active_count;
4053 13407283 }
4054 13407283 }
4055
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4911060 times.
4911060 else if(idle_count < MAX_IDLE)
4056 {
4057 4911060 ++idle_count;
4058 4911060 active_count = 0;
4059 4911060 }
4060
4061 18318343 mx = mouse_x;
4062 18318343 my = mouse_y;
4063 18318343 mz = mouse_z;
4064 18318343 mb = mouse_b;
4065
4066 18318343 return idle_count;
4067 }
4068
4069 int32_t onGoFast()
4070 {
4071 cheats_enqueue(Cheat::Fast);
4072 return D_O_K;
4073 }
4074
4075 int32_t onKillCheat()
4076 {
4077 cheats_enqueue(Cheat::Kill);
4078 return D_O_K;
4079 }
4080
4081 int32_t onSecretsCheat()
4082 {
4083 cheats_enqueue(Cheat::TrigSecrets);
4084 return D_O_K;
4085 }
4086 int32_t onSecretsCheatPerm()
4087 {
4088 cheats_enqueue(Cheat::TrigSecretsPerm);
4089 return D_O_K;
4090 }
4091
4092 int32_t onShowLayer0()
4093 {
4094 show_layer_0 = !show_layer_0;
4095 return D_O_K;
4096 }
4097 int32_t onShowLayer1()
4098 {
4099 show_layer_1 = !show_layer_1;
4100 return D_O_K;
4101 }
4102 int32_t onShowLayer2()
4103 {
4104 show_layer_2 = !show_layer_2;
4105 return D_O_K;
4106 }
4107 int32_t onShowLayer3()
4108 {
4109 show_layer_3 = !show_layer_3;
4110 return D_O_K;
4111 }
4112 int32_t onShowLayer4()
4113 {
4114 show_layer_4 = !show_layer_4;
4115 return D_O_K;
4116 }
4117 int32_t onShowLayer5()
4118 {
4119 show_layer_5 = !show_layer_5;
4120 return D_O_K;
4121 }
4122 int32_t onShowLayer6()
4123 {
4124 show_layer_6 = !show_layer_6;
4125 return D_O_K;
4126 }
4127 int32_t onShowLayerO()
4128 {
4129 show_layer_over=!show_layer_over;
4130 return D_O_K;
4131 }
4132 int32_t onShowLayerP()
4133 {
4134 show_layer_push=!show_layer_push;
4135 return D_O_K;
4136 }
4137 int32_t onShowLayerS()
4138 {
4139 show_sprites=!show_sprites;
4140 return D_O_K;
4141 }
4142 int32_t onShowLayerF()
4143 {
4144 show_ffcs=!show_ffcs;
4145 return D_O_K;
4146 }
4147 int32_t onShowLayerW()
4148 {
4149 show_walkflags=!show_walkflags;
4150 if(show_walkflags)
4151 show_effectflags = false;
4152 return D_O_K;
4153 }
4154 int32_t onShowLayerE()
4155 {
4156 show_effectflags=!show_effectflags;
4157 if(show_effectflags)
4158 show_walkflags = false;
4159 return D_O_K;
4160 }
4161 int32_t onShowFFScripts()
4162 {
4163 show_ff_scripts=!show_ff_scripts;
4164 return D_O_K;
4165 }
4166 int32_t onShowHitboxes()
4167 {
4168 show_hitboxes=!show_hitboxes;
4169 return D_O_K;
4170 }
4171 int32_t onShowInfoOpacity()
4172 {
4173 info_opacity = vbound(getnumber("Debug Info Opacity",info_opacity),0,255);
4174 zc_set_config("zc","debug_info_opacity",info_opacity);
4175 return D_O_K;
4176 }
4177
4178 int32_t onLightSwitch()
4179 {
4180 cheats_enqueue(Cheat::Light);
4181 return D_O_K;
4182 }
4183
4184 int32_t onGoTo();
4185 int32_t onGoToComplete();
4186
4187 18318343 bool handle_close_btn_quit()
4188 {
4189
1/2
✓ Branch 0 taken 18318343 times.
✗ Branch 1 not taken.
18318343 if(close_button_quit)
4190 {
4191 close_button_quit=false;
4192 f_Quit(qEXIT);
4193 }
4194 18318343 return (exiting_program = Quit==qEXIT);
4195 }
4196
4197 18318343 void syskeys()
4198 {
4199 18318343 update_system_keys();
4200
4201 int32_t oldtitle_version;
4202
4203 18318343 poll_joystick();
4204
4205 18318343 handle_close_btn_quit();
4206
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 18318343 times.
18318343 if(Quit == qEXIT) return;
4207
4208
2/10
✓ Branch 0 taken 18318343 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 18318343 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
18318343 if(rMbtn() || (gui_mouse_b() && !mouse_down && ClickToFreeze &&!disableClickToFreeze))
4209 {
4210 System();
4211 }
4212
4213 18318343 mouse_down=gui_mouse_b();
4214
4215
1/2
✓ Branch 0 taken 18318343 times.
✗ Branch 1 not taken.
18318343 if(zc_read_system_key(KEY_F1))
4216 {
4217 if(zc_get_system_key(KEY_ZC_LCONTROL) || zc_get_system_key(KEY_ZC_RCONTROL))
4218 {
4219 halt=!halt;
4220 //zinit.subscreen=(zinit.subscreen+1)%ssdtMAX;
4221 }
4222 else
4223 {
4224 Throttlefps=!Throttlefps;
4225 zc_set_config(cfg_sect,"throttlefps", (int32_t)Throttlefps);
4226 }
4227 }
4228
4229
1/2
✓ Branch 0 taken 18318343 times.
✗ Branch 1 not taken.
18318343 if(zc_read_system_key(KEY_F2))
4230 {
4231 ShowFPS=!ShowFPS;
4232 zc_set_config(cfg_sect,"showfps",(int32_t)ShowFPS);
4233 }
4234
4235
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 18318343 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
18318343 if(zc_read_system_key(KEY_F3) && Playing) Paused=!Paused;
4236
4237
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 18318343 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
18318343 if(zc_read_system_key(KEY_F4) && Playing)
4238 {
4239 Paused=true;
4240 Advance=true;
4241 }
4242
4243
1/2
✓ Branch 0 taken 18318343 times.
✗ Branch 1 not taken.
18318343 if(zc_read_system_key(KEY_F6)) onTryQuit();
4244
4245 #ifndef ALLEGRO_MACOSX
4246
1/2
✓ Branch 0 taken 18318343 times.
✗ Branch 1 not taken.
18318343 if(zc_read_system_key(KEY_F9)) f_Quit(qRESET);
4247
4248
1/2
✓ Branch 0 taken 18318343 times.
✗ Branch 1 not taken.
18318343 if(zc_read_system_key(KEY_F10)) f_Quit(qEXIT);
4249 #else
4250 if(zc_read_system_key(KEY_F7)) f_Quit(qRESET);
4251
4252 if(zc_read_system_key(KEY_F8)) f_Quit(qEXIT);
4253 #endif
4254
1/8
✗ Branch 0 not taken.
✓ Branch 1 taken 18318343 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
18318343 if(zc_read_system_key(KEY_F5)&&(Playing && currscr<128 && DMaps[currdmap].flags&dmfVIEWMAP)) onSaveMapPic();
4255
4256
1/2
✓ Branch 0 taken 18318343 times.
✗ Branch 1 not taken.
18318343 if (zc_read_system_key(KEY_F12))
4257 {
4258 onSnapshot();
4259 }
4260
4261
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 18318343 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
18318343 if(debug_enabled && zc_read_system_key(KEY_TAB))
4262 set_debug(!get_debug());
4263
4264
1/2
✓ Branch 0 taken 18318343 times.
✗ Branch 1 not taken.
18318343 if(CheatModifierKeys())
4265 {
4266 for(Cheat c = (Cheat)1; c < Cheat::Last; c = (Cheat)(c+1))
4267 {
4268 if(!bindable_cheat(c))
4269 continue;
4270 if(get_debug() || cheat >= cheat_lvl(c))
4271 {
4272 if(checkcheat(c))
4273 cheats_hit_bind(c);
4274 }
4275 }
4276 }
4277
4278
1/2
✓ Branch 0 taken 18318343 times.
✗ Branch 1 not taken.
18318343 if(volkeys)
4279 {
4280 if(zc_read_system_key(KEY_PGUP)) master_volume(-1,midi_volume+8);
4281
4282 if(zc_read_system_key(KEY_PGDN)) master_volume(-1,midi_volume==255?248:midi_volume-8);
4283
4284 if(zc_read_system_key(KEY_HOME)) master_volume(digi_volume+8,-1);
4285
4286 if(zc_read_system_key(KEY_END)) master_volume(digi_volume==255?248:digi_volume-8,-1);
4287 }
4288
4289
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 18318343 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
18318343 if(!get_debug() || !SystemKeys || replay_is_replaying())
4290 18318343 goto bottom;
4291
4292 if(zc_readkey(KEY_P)) Paused=!Paused;
4293
4294 if(zc_readkey(KEY_A))
4295 {
4296 Paused=true;
4297 Advance=true;
4298 }
4299
4300 if(zc_readkey(KEY_G)) db=(db==999)?0:999;
4301 #ifndef ALLEGRO_MACOSX
4302 if(zc_readkey(KEY_F8)) Showpal=!Showpal;
4303
4304 if(zc_readkey(KEY_F7))
4305 {
4306 Matrix(ss_speed, ss_density, 0);
4307 game_pal();
4308 }
4309 #else
4310 // The reason these are different on Mac in the first place is that
4311 // the OS doesn't let us use F9 and F10...
4312 if(zc_readkey(KEY_F10)) Showpal=!Showpal;
4313
4314 if(zc_readkey(KEY_F9))
4315 {
4316 Matrix(ss_speed, ss_density, 0);
4317 game_pal();
4318 }
4319 #endif
4320 if(zc_readkey(KEY_PLUS_PAD) || zc_readkey(KEY_EQUALS))
4321 {
4322 //change containers
4323 if(zc_getkey(KEY_ZC_LCONTROL) || zc_getkey(KEY_ZC_RCONTROL))
4324 {
4325 //magic containers
4326 if(zc_getkey(KEY_LSHIFT) || zc_getkey(KEY_RSHIFT))
4327 {
4328 game->set_maxmagic(zc_min(game->get_maxmagic()+game->get_mp_per_block(),game->get_mp_per_block()*8));
4329 }
4330 else
4331 {
4332 game->set_maxlife(zc_min(game->get_maxlife()+game->get_hp_per_heart(),game->get_hp_per_heart()*24));
4333 }
4334 }
4335 else
4336 {
4337 if(zc_getkey(KEY_LSHIFT) || zc_getkey(KEY_RSHIFT))
4338 {
4339 game->set_magic(zc_min(game->get_magic()+1,game->get_maxmagic()));
4340 }
4341 else
4342 {
4343 game->set_life(zc_min(game->get_life()+1,game->get_maxlife()));
4344 }
4345 }
4346 }
4347
4348 if(zc_readkey(KEY_MINUS_PAD) || zc_readkey(KEY_MINUS))
4349 {
4350 //change containers
4351 if(zc_getkey(KEY_ZC_LCONTROL) || zc_getkey(KEY_ZC_RCONTROL))
4352 {
4353 //magic containers
4354 if(zc_getkey(KEY_LSHIFT) || zc_getkey(KEY_RSHIFT))
4355 {
4356 game->set_maxmagic(zc_max(game->get_maxmagic()-game->get_mp_per_block(),0));
4357 game->set_magic(zc_min(game->get_maxmagic(), game->get_magic()));
4358 //heart containers
4359 }
4360 else
4361 {
4362 game->set_maxlife(zc_max(game->get_maxlife()-game->get_hp_per_heart(),game->get_hp_per_heart()));
4363 game->set_life(zc_min(game->get_maxlife(), game->get_life()));
4364 }
4365 }
4366 else
4367 {
4368 if(zc_getkey(KEY_LSHIFT) || zc_getkey(KEY_RSHIFT))
4369 {
4370 game->set_magic(zc_max(game->get_magic()-1,0));
4371 }
4372 else
4373 {
4374 game->set_life(zc_max(game->get_life()-1,0));
4375 }
4376 }
4377 }
4378
4379 if(zc_readkey(KEY_COMMA)) jukebox(currmidi-1);
4380
4381 if(zc_readkey(KEY_STOP)) jukebox(currmidi+1);
4382
4383 verifyBothWeapons();
4384
4385 bottom:
4386
4387
1/2
✓ Branch 0 taken 18318343 times.
✗ Branch 1 not taken.
18318343 if(input_idle(true) > after_time())
4388 {
4389 Matrix(ss_speed, ss_density, 0);
4390 game_pal();
4391 }
4392 18318343 }
4393
4394 1114675 void checkQuitKeys()
4395 {
4396 #ifndef ALLEGRO_MACOSX
4397
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1114675 times.
1114675 if(key[KEY_F9]) f_Quit(qRESET);
4398
4399
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1114675 times.
1114675 if(key[KEY_F10]) f_Quit(qEXIT);
4400 #else
4401 if(key[KEY_F7]) f_Quit(qRESET);
4402
4403 if(key[KEY_F8]) f_Quit(qEXIT);
4404 #endif
4405 1114675 }
4406
4407 18318543 bool CheatModifierKeys()
4408 {
4409 // Cheats are replayed via the X cheat step, no need to check for keyboard input
4410 // to trigger cheats.
4411
2/2
✓ Branch 0 taken 18318243 times.
✓ Branch 1 taken 300 times.
18318543 if (replay_is_replaying())
4412 18318243 return false;
4413
4414
3/4
✓ Branch 0 taken 100 times.
✓ Branch 1 taken 200 times.
✓ Branch 2 taken 100 times.
✗ Branch 3 not taken.
300 if ( ( cheat_modifier_keys[0] > 0 && key[cheat_modifier_keys[0]] ) ||
4415
2/2
✓ Branch 0 taken 100 times.
✓ Branch 1 taken 100 times.
200 ( cheat_modifier_keys[1] > 0 && key[cheat_modifier_keys[1]] ) ||
4416
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 100 times.
100 (cheat_modifier_keys[0] <= 0 && cheat_modifier_keys[1] <= 0))
4417 {
4418
0/4
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
200 if ( ( cheat_modifier_keys[2] <= 0 || key[cheat_modifier_keys[2]] ) ||
4419 ( cheat_modifier_keys[3] > 0 && key[cheat_modifier_keys[3]] ) ||
4420 (cheat_modifier_keys[2] <= 0 && cheat_modifier_keys[3] <= 0))
4421 {
4422 return true;
4423 }
4424 }
4425 100 return false;
4426 18318343 }
4427
4428 //99:05:54, for some reason?
4429 #define OLDMAXTIME 21405240
4430 //9000:00:00, the highest even-thousand hour fitting within 32b signed. This is 375 *DAYS*.
4431 #define MAXTIME 1944000000
4432
4433 18319686 void advanceframe(bool allowwavy, bool sfxcleanup, bool allowF6Script)
4434 {
4435
1/2
✓ Branch 0 taken 18319686 times.
✗ Branch 1 not taken.
18319686 if(zcmusic!=NULL)
4436 {
4437 zcmusic_poll();
4438 }
4439 18319686 zcmixer_update(zcmixer, emusic_volume, FFCore.usr_music_volume, get_qr(qr_OLD_SCRIPT_VOLUME));
4440
4441 18319686 updatescr(allowwavy);
4442
4443 18319686 Advance=false;
4444
2/6
✗ Branch 0 not taken.
✓ Branch 1 taken 18319686 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 18319686 times.
18319686 while(Paused && !Advance && !Quit)
4445 {
4446 // have to call this, otherwise we'll get an infinite loop
4447 syskeys();
4448 if(allowF6Script)
4449 {
4450 FFCore.runF6Engine();
4451 }
4452
4453 #ifdef _WIN32
4454
4455 if(use_dwm_flush)
4456 {
4457 do_DwmFlush();
4458 }
4459
4460 #endif
4461
4462 // to keep music playing
4463 if(zcmusic!=NULL)
4464 {
4465 zcmusic_poll();
4466 }
4467
4468 update_hw_screen();
4469 }
4470
4471
2/2
✓ Branch 0 taken 18318377 times.
✓ Branch 1 taken 1309 times.
18319686 if(Quit)
4472 1309 return;
4473
4474
3/4
✓ Branch 0 taken 17805534 times.
✓ Branch 1 taken 512843 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 17805534 times.
18318377 if(Playing && game->get_time()<unsigned(get_qr(qr_GREATER_MAX_TIME) ? MAXTIME : OLDMAXTIME))
4475 17805534 game->change_time(1);
4476
4477 // Many mistakes have been make re: inputs, and we are stuck with many replays relying on those mistakes.
4478
4479 18318377 bool should_reset_down_state = !get_qr(qr_BROKEN_INPUT_DOWN_STATE);
4480
2/2
✓ Branch 0 taken 8608763 times.
✓ Branch 1 taken 9709614 times.
18318377 if (replay_version_check(0, 16))
4481 9709614 should_reset_down_state = replay_version_check(11, 16);
4482
2/2
✓ Branch 0 taken 14985380 times.
✓ Branch 1 taken 3332997 times.
18318377 if (should_reset_down_state)
4483 {
4484
2/2
✓ Branch 0 taken 59993946 times.
✓ Branch 1 taken 3332997 times.
63326943 for (int i = 0; i < ZC_CONTROL_STATES; i++)
4485 59993946 down_control_states[i] = raw_control_state[i];
4486 3332997 }
4487
4488
2/2
✓ Branch 0 taken 34 times.
✓ Branch 1 taken 18318343 times.
18318377 if (replay_is_active())
4489 {
4490
2/2
✓ Branch 0 taken 1545423 times.
✓ Branch 1 taken 16772920 times.
18318343 if (replay_version_check(3))
4491 16772920 replay_poll();
4492
4493
4/4
✓ Branch 0 taken 7388911 times.
✓ Branch 1 taken 10929432 times.
✓ Branch 2 taken 100535 times.
✓ Branch 3 taken 7288376 times.
18318343 if (replay_version_check(11) || replay_version_check(6, 8))
4494 11029967 replay_peek_input();
4495 18318343 }
4496
4497 18318377 load_control_called_this_frame = false;
4498
4499 18318377 poll_keyboard();
4500 18318377 update_keys();
4501
4502 18318377 ++frame;
4503
4504
2/2
✓ Branch 0 taken 134 times.
✓ Branch 1 taken 18318243 times.
18318377 if (replay_is_replaying())
4505 18318243 replay_do_cheats();
4506 18318377 syskeys();
4507
4508 // The mouse variables can change from the mouse thread at anytime during a frame,
4509 // so save the result at the start so that replaying is consistent.
4510 18318377 script_mouse_x = gui_mouse_x();
4511 18318377 script_mouse_y = gui_mouse_y();
4512 18318377 script_mouse_z = mouse_z;
4513 18318377 script_mouse_b = mouse_b;
4514
4515 // Cheats used via the System menu (called by syskeys) will call cheats_enqueue. syskeys
4516 // is called just above, and in the paused loop above, so the queue-and-defer-slightly
4517 // approach here means it doesn't matter which call adds the cheat.
4518 18318377 cheats_execute_queued();
4519
4520
2/2
✓ Branch 0 taken 134 times.
✓ Branch 1 taken 18318243 times.
18318377 if (replay_is_replaying())
4521 18318243 replay_peek_quit();
4522
2/2
✓ Branch 0 taken 18318322 times.
✓ Branch 1 taken 55 times.
18318377 if (GameFlags & GAMEFLAG_TRYQUIT)
4523 55 replay_step_quit(0);
4524
2/2
✓ Branch 0 taken 3319 times.
✓ Branch 1 taken 18315058 times.
18318377 if(allowF6Script)
4525 18315058 FFCore.runF6Engine();
4526
2/2
✓ Branch 0 taken 714 times.
✓ Branch 1 taken 18317663 times.
18318377 if (Quit)
4527 714 replay_step_quit(Quit);
4528
4529 #ifdef _WIN32
4530
4531 if(use_dwm_flush)
4532 {
4533 do_DwmFlush();
4534 }
4535
4536 #endif
4537
4538
2/2
✓ Branch 0 taken 208642 times.
✓ Branch 1 taken 18109735 times.
18318377 if(sfxcleanup)
4539 18109735 sfx_cleanup();
4540
4541 18318377 jit_poll();
4542
4543 #ifdef __EMSCRIPTEN__
4544 // Yield the main thread back to the browser occasionally.
4545 if (is_headless())
4546 {
4547 static int rate = 10000;
4548 static int force_yield = rate;
4549 if (force_yield++ >= rate)
4550 {
4551 force_yield = 0;
4552 emscripten_sleep(0);
4553 }
4554 }
4555 #endif
4556
4557
3/4
✓ Branch 0 taken 100 times.
✓ Branch 1 taken 18318277 times.
✓ Branch 2 taken 100 times.
✗ Branch 3 not taken.
18318377 if (zqtesting_mode && test_mode_auto_restart)
4558 {
4559 static auto last_write_time = fs::last_write_time(qstpath);
4560 static auto last_check = std::chrono::system_clock::now();
4561
4562 if (std::chrono::system_clock::now() - last_check > 200ms)
4563 {
4564 last_check = std::chrono::system_clock::now();
4565 auto write_time = fs::last_write_time(qstpath);
4566 if (last_write_time != write_time)
4567 {
4568 last_write_time = write_time;
4569 disableClickToFreeze = false;
4570 Quit = qRESET;
4571 replay_quit();
4572 }
4573 }
4574 }
4575 18319686 }
4576
4577 589 void zapout()
4578 {
4579 589 set_clip_rect(scrollbuf, 0, 0, scrollbuf->w, scrollbuf->h);
4580 589 blit(framebuf,scrollbuf,0,0,256,0,256,224);
4581
4582 589 FFCore.runGenericPassiveEngine(SCR_TIMING_END_FRAME);
4583 589 script_drawing_commands.Clear();
4584
4585 // zap out
4586
2/2
✓ Branch 0 taken 589 times.
✓ Branch 1 taken 14136 times.
14725 for(int32_t i=1; i<=24; i++)
4587 {
4588 14136 draw_fuzzy(i);
4589 14136 advanceframe(true);
4590
4591
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 14136 times.
14136 if(Quit)
4592 {
4593 break;
4594 }
4595 14136 }
4596 589 }
4597
4598 587 void zapin()
4599 {
4600 587 FFCore.warpScriptCheck();
4601 587 draw_screen(tmpscr);
4602 587 set_clip_rect(scrollbuf, 0, 0, scrollbuf->w, scrollbuf->h);
4603 587 blit(framebuf,scrollbuf,0,0,256,0,256,224);
4604
4605 // zap out
4606 587 FFCore.runGenericPassiveEngine(SCR_TIMING_END_FRAME);
4607
2/2
✓ Branch 0 taken 587 times.
✓ Branch 1 taken 14088 times.
14675 for(int32_t i=24; i>=1; i--)
4608 {
4609 14088 draw_fuzzy(i);
4610 14088 advanceframe(true);
4611
4612
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 14088 times.
14088 if(Quit)
4613 {
4614 break;
4615 }
4616 14088 }
4617 587 }
4618
4619
4620 235 void wavyout(bool showhero)
4621 {
4622 235 draw_screen(tmpscr, showhero);
4623
4624 235 BITMAP *wavebuf = create_bitmap_ex(8,288,224);
4625 235 clear_to_color(wavebuf,0);
4626 235 blit(framebuf,wavebuf,0,0,16,0,256,224);
4627
4628 static PALETTE wavepal;
4629
4630 int32_t ofs;
4631 235 int32_t amplitude=8;
4632
4633 235 int32_t wavelength=4;
4634 235 double palpos=0, palstep=4, palstop=126;
4635
4636 235 FFCore.runGenericPassiveEngine(SCR_TIMING_END_FRAME);
4637
2/2
✓ Branch 0 taken 234 times.
✓ Branch 1 taken 9845 times.
10079 for(int32_t i=0; i<168; i+=wavelength)
4638 {
4639
2/2
✓ Branch 0 taken 2520320 times.
✓ Branch 1 taken 9845 times.
2530165 for(int32_t l=0; l<256; l++)
4640 {
4641 2520320 wavepal[l].r=vbound(int32_t(RAMpal[l].r+((palpos/palstop)*(255-RAMpal[l].r))),0,255);
4642 2520320 wavepal[l].g=vbound(int32_t(RAMpal[l].g+((palpos/palstop)*(255-RAMpal[l].g))),0,255);
4643 2520320 wavepal[l].b=vbound(int32_t(RAMpal[l].b+((palpos/palstop)*(255-RAMpal[l].b))),0,255);
4644 2520320 }
4645
4646 9845 palpos+=palstep;
4647
4648
1/2
✓ Branch 0 taken 9845 times.
✗ Branch 1 not taken.
9845 if(palpos>=0)
4649 {
4650 9845 hw_palette = &wavepal;
4651 9845 update_hw_pal = true;
4652 9845 }
4653 else
4654 {
4655 hw_palette = &RAMpal;
4656 update_hw_pal = true;
4657 }
4658
4659
2/2
✓ Branch 0 taken 1653960 times.
✓ Branch 1 taken 9845 times.
1663805 for(int32_t j=0; j+playing_field_offset<224; j++)
4660 {
4661
2/2
✓ Branch 0 taken 423413760 times.
✓ Branch 1 taken 1653960 times.
425067720 for(int32_t k=0; k<256; k++)
4662 {
4663 423413760 ofs=0;
4664
4665
4/4
✓ Branch 0 taken 206448640 times.
✓ Branch 1 taken 216965120 times.
✓ Branch 2 taken 103224320 times.
✓ Branch 3 taken 103224320 times.
423413760 if((j<i)&&(j&1))
4666 {
4667 103224320 ofs=int32_t(zc::math::Sin((double(i+j)*2*PI/168.0))*amplitude);
4668 103224320 }
4669
4670 423413760 framebuf->line[j+playing_field_offset][k]=wavebuf->line[j+playing_field_offset][k+ofs+16];
4671 423413760 }
4672 1653960 }
4673
4674 9845 advanceframe(true);
4675
4676
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 9844 times.
9845 if(Quit)
4677 1 break;
4678 9844 }
4679
4680 235 destroy_bitmap(wavebuf);
4681
4682 235 hw_palette = &RAMpal;
4683 235 update_hw_pal = true;
4684 235 }
4685
4686 232 void wavyin()
4687 {
4688 232 draw_screen(tmpscr);
4689
4690 232 BITMAP *wavebuf = create_bitmap_ex(8,288,224);
4691 232 clear_to_color(wavebuf,0);
4692 232 blit(framebuf,wavebuf,0,0,16,0,256,224);
4693
4694 static PALETTE wavepal;
4695
4696 232 refreshpal=false;
4697 int32_t ofs;
4698 232 int32_t amplitude=8;
4699 232 int32_t wavelength=4;
4700 232 double palpos=168, palstep=4, palstop=126;
4701
4702 232 FFCore.runGenericPassiveEngine(SCR_TIMING_END_FRAME);
4703
2/2
✓ Branch 0 taken 231 times.
✓ Branch 1 taken 9703 times.
9934 for(int32_t i=0; i<168; i+=wavelength)
4704 {
4705
2/2
✓ Branch 0 taken 2483968 times.
✓ Branch 1 taken 9703 times.
2493671 for(int32_t l=0; l<256; l++)
4706 {
4707 2483968 wavepal[l].r=vbound(int32_t(RAMpal[l].r+((palpos/palstop)*(255-RAMpal[l].r))),0,255);
4708 2483968 wavepal[l].g=vbound(int32_t(RAMpal[l].g+((palpos/palstop)*(255-RAMpal[l].g))),0,255);
4709 2483968 wavepal[l].b=vbound(int32_t(RAMpal[l].b+((palpos/palstop)*(255-RAMpal[l].b))),0,255);
4710 2483968 }
4711
4712 9703 palpos-=palstep;
4713
4714
1/2
✓ Branch 0 taken 9703 times.
✗ Branch 1 not taken.
9703 if(palpos>=0)
4715 {
4716 9703 hw_palette = &wavepal;
4717 9703 update_hw_pal = true;
4718 9703 }
4719 else
4720 {
4721 hw_palette = &RAMpal;
4722 update_hw_pal = true;
4723 }
4724
4725
2/2
✓ Branch 0 taken 1630104 times.
✓ Branch 1 taken 9703 times.
1639807 for(int32_t j=0; j+playing_field_offset<224; j++)
4726 {
4727
2/2
✓ Branch 0 taken 417306624 times.
✓ Branch 1 taken 1630104 times.
418936728 for(int32_t k=0; k<256; k++)
4728 {
4729 417306624 ofs=0;
4730
4731
4/4
✓ Branch 0 taken 211158272 times.
✓ Branch 1 taken 206148352 times.
✓ Branch 2 taken 106821120 times.
✓ Branch 3 taken 104337152 times.
417306624 if((j<(167-i))&&(j&1))
4732 {
4733 104337152 ofs=int32_t(zc::math::Sin((double(i+j)*2*PI/168.0))*amplitude);
4734 104337152 }
4735
4736 417306624 framebuf->line[j+playing_field_offset][k]=wavebuf->line[j+playing_field_offset][k+ofs+16];
4737 417306624 }
4738 1630104 }
4739
4740 9703 advanceframe(true);
4741
4742
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 9702 times.
9703 if(Quit)
4743 1 break;
4744 9702 }
4745
4746 232 destroy_bitmap(wavebuf);
4747
4748 232 hw_palette = &RAMpal;
4749 232 update_hw_pal = true;
4750 232 }
4751
4752 4335 void blackscr(int32_t fcnt,bool showsubscr)
4753 {
4754 4335 reset_pal_cycling();
4755 4335 script_drawing_commands.Clear();
4756
4757 4335 FFCore.warpScriptCheck();
4758 4335 bool showtime = game->should_show_time();
4759
2/2
✓ Branch 0 taken 4328 times.
✓ Branch 1 taken 129607 times.
133935 while(fcnt>0)
4760 {
4761 129607 clear_bitmap(framebuf);
4762
4763
2/2
✓ Branch 0 taken 59250 times.
✓ Branch 1 taken 70357 times.
129607 if(showsubscr)
4764 {
4765 70357 put_passive_subscr(framebuf,0,passive_subscreen_offset,showtime,sspUP);
4766
3/4
✓ Branch 0 taken 70357 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1230 times.
✓ Branch 3 taken 69127 times.
70357 if(get_qr(qr_SCRIPTDRAWSINWARPS) || (get_qr(qr_PASSIVE_SUBSCRIPT_RUNS_WHEN_GAME_IS_FROZEN)))
4767 {
4768 1230 do_script_draws(framebuf, tmpscr, 0, playing_field_offset);
4769 1230 }
4770 70357 }
4771
4772 129607 advanceframe(true);
4773
4774
2/2
✓ Branch 0 taken 7 times.
✓ Branch 1 taken 129600 times.
129607 if(Quit)
4775 7 break;
4776
4777 129600 --fcnt;
4778 }
4779 4335 }
4780
4781 2643 void openscreen(int32_t shape)
4782 {
4783 2643 reset_pal_cycling();
4784 2643 black_opening_count=0;
4785
4786
3/4
✓ Branch 0 taken 522 times.
✓ Branch 1 taken 2121 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 522 times.
2643 if(COOLSCROLL || shape>-1)
4787 {
4788 2121 open_black_opening(HeroX()+8, (HeroY()-HeroZ()-HeroFakeZ())+8+playing_field_offset, true, shape);
4789 2121 return;
4790 }
4791 else
4792 {
4793 522 Hero.setDontDraw(true);
4794 522 show_subscreen_dmap_dots=false;
4795 522 show_subscreen_numbers=false;
4796 522 show_subscreen_life=false;
4797 }
4798
4799 522 int32_t x=128;
4800
4801 522 FFCore.warpScriptCheck();
4802
2/2
✓ Branch 0 taken 522 times.
✓ Branch 1 taken 41760 times.
42282 for(int32_t i=0; i<80; i++)
4803 {
4804 41760 draw_screen(tmpscr);
4805 41760 x=128-(((i*128/80)/8)*8);
4806
4807
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 41760 times.
41760 if(x>0)
4808 {
4809 41760 rectfill(framebuf,0,playing_field_offset,x,167+playing_field_offset,0);
4810 41760 rectfill(framebuf,256-x,playing_field_offset,255,167+playing_field_offset,0);
4811 41760 }
4812
4813 41760 advanceframe(true);
4814
4815
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 41760 times.
41760 if(Quit)
4816 {
4817 break;
4818 }
4819 41760 }
4820
4821 522 Hero.setDontDraw(false);
4822 522 show_subscreen_items=true;
4823 522 show_subscreen_dmap_dots=true;
4824 522 show_subscreen_numbers=true;
4825 522 show_subscreen_life=true;
4826 2643 }
4827
4828 4 void closescreen(int32_t shape)
4829 {
4830 4 reset_pal_cycling();
4831 4 black_opening_count=0;
4832
4833
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
4 if(COOLSCROLL || shape>-1)
4834 {
4835 4 close_black_opening(HeroX()+8, (HeroY()-HeroZ()-HeroFakeZ())+8+playing_field_offset, true, shape);
4836 4 return;
4837 }
4838 else
4839 {
4840 Hero.setDontDraw(true);
4841 show_subscreen_dmap_dots=false;
4842 show_subscreen_numbers=false;
4843 // show_subscreen_items=false;
4844 show_subscreen_life=false;
4845 }
4846
4847 int32_t x=128;
4848
4849 FFCore.warpScriptCheck();
4850 for(int32_t i=79; i>=0; --i)
4851 {
4852 draw_screen(tmpscr);
4853 x=128-(((i*128/80)/8)*8);
4854
4855 if(x>0)
4856 {
4857 rectfill(framebuf,0,playing_field_offset,x,167+playing_field_offset,0);
4858 rectfill(framebuf,256-x,playing_field_offset,255,167+playing_field_offset,0);
4859 }
4860
4861 advanceframe(true);
4862
4863 if(Quit)
4864 {
4865 break;
4866 }
4867 }
4868
4869 Hero.setDontDraw(false);
4870 show_subscreen_items=true;
4871 show_subscreen_dmap_dots=true;
4872 4 }
4873
4874 296 int32_t TriforceCount()
4875 {
4876 296 int32_t c=0;
4877
4878
2/2
✓ Branch 0 taken 2368 times.
✓ Branch 1 taken 296 times.
2664 for(int32_t i=1; i<=8; i++)
4879
2/2
✓ Branch 0 taken 484 times.
✓ Branch 1 taken 1884 times.
4252 if(game->lvlitems[i]&liTRIFORCE)
4880 1884 ++c;
4881
4882 296 return c;
4883 }
4884
4885 int32_t onCustomGame()
4886 {
4887 auto save = get_unset_save_slot();
4888 if (!save)
4889 return D_CLOSE;
4890
4891 if (prompt_for_quest_path(save->header->qstpath))
4892 {
4893 save->header->qstpath = qstpath;
4894 return D_O_K;
4895 }
4896
4897 return D_CLOSE;
4898 }
4899
4900 int32_t onContinue()
4901 {
4902 return D_CLOSE;
4903 }
4904
4905 int32_t onThrottleFPS()
4906 {
4907 Throttlefps = !Throttlefps;
4908 zc_set_config(cfg_sect,"throttlefps", (int32_t)Throttlefps);
4909 return D_O_K;
4910 }
4911
4912 int32_t onWinPosSave()
4913 {
4914 SaveWinPos = !SaveWinPos;
4915 zc_set_config(cfg_sect,"save_window_position",(int32_t)SaveWinPos);
4916 return D_O_K;
4917 }
4918 int32_t onIntegerScaling()
4919 {
4920 scaleForceInteger = !scaleForceInteger;
4921 zc_set_config("zeldadx","scaling_force_integer",(int)scaleForceInteger);
4922 return D_O_K;
4923 }
4924 int32_t onStretchGame()
4925 {
4926 stretchGame = !stretchGame;
4927 zc_set_config("zeldadx","stretch_game_area",stretchGame?1:0);
4928 return D_O_K;
4929 }
4930
4931 int32_t onClickToFreeze()
4932 {
4933 ClickToFreeze = !ClickToFreeze;
4934 zc_set_config(cfg_sect,"clicktofreeze", (int32_t)ClickToFreeze);
4935 return D_O_K;
4936 }
4937
4938 int32_t OnSaveZCConfig()
4939 {
4940 if(jwin_alert3(
4941 "Save Configuration",
4942 "Are you sure that you wish to save your present configuration settings?",
4943 "This will overwrite your prior settings!",
4944 NULL,
4945 "&Yes",
4946 "&No",
4947 NULL,
4948 'y',
4949 'n',
4950 0,
4951 get_zc_font(font_lfont)) == 1)
4952 {
4953 save_game_configs();
4954 return D_O_K;
4955 }
4956 else return D_O_K;
4957 }
4958
4959 int32_t OnnClearQuestDir()
4960 {
4961 auto current_path = fs::current_path() / "quests";
4962 if(jwin_alert3(
4963 "Clear Current Directory Cache",
4964 "Are you sure that you wish to reset where ZC Player looks for quests?",
4965 fmt::format("The new directory will be: {}", current_path.string()).c_str(),
4966 NULL,
4967 "&Yes",
4968 "&No",
4969 NULL,
4970 'y',
4971 'n',
4972 0,
4973 get_zc_font(font_lfont)) == 1)
4974 {
4975 zc_set_config("zeldadx","quest_dir","quests");
4976 flush_config_file();
4977 strcpy(qstdir,"quests");
4978 #ifdef __EMSCRIPTEN__
4979 em_sync_fs();
4980 #endif
4981 return D_O_K;
4982 }
4983 else return D_O_K;
4984 }
4985
4986 int32_t onConsole()
4987 {
4988 if ( !console_enabled )
4989 {
4990 AlertDialog("ZC Console",
4991 "Open the ZC Console?"
4992 "\nThis will display any messages logged by scripts,"
4993 " including errors.",
4994 [&](bool ret,bool)
4995 {
4996 if(ret)
4997 {
4998 FFCore.ZScriptConsole(true);
4999 }
5000 }).show();
5001 return D_O_K;
5002 }
5003 else
5004 {
5005 FFCore.ZScriptConsole(false);
5006 return D_O_K;
5007 }
5008 }
5009
5010 int32_t onClrConsoleOnReload()
5011 {
5012 clearConsoleOnReload = !clearConsoleOnReload;
5013 zc_set_config("CONSOLE","clear_console_on_reload",clearConsoleOnReload?1:0);
5014 return D_O_K;
5015 }
5016 int32_t onClrConsoleOnLoad()
5017 {
5018 clearConsoleOnLoad = !clearConsoleOnLoad;
5019 zc_set_config("CONSOLE","clear_console_on_load",clearConsoleOnLoad?1:0);
5020 return D_O_K;
5021 }
5022
5023
5024 int32_t onFrameSkip()
5025 {
5026 FrameSkip = !FrameSkip;
5027 return D_O_K;
5028 }
5029
5030 int32_t onSaveDragResize()
5031 {
5032 SaveDragResize = !SaveDragResize;
5033 zc_set_config(cfg_sect,"save_drag_resize",(int32_t)SaveDragResize);
5034 return D_O_K;
5035 }
5036
5037 int32_t onDragAspect()
5038 {
5039 DragAspect = !DragAspect;
5040 zc_set_config(cfg_sect,"drag_aspect",(int32_t)DragAspect);
5041 return D_O_K;
5042 }
5043
5044 int32_t onTransLayers()
5045 {
5046 TransLayers = !TransLayers;
5047 zc_set_config(cfg_sect,"translayers",(int32_t)TransLayers);
5048 return D_O_K;
5049 }
5050
5051 int32_t onNESquit()
5052 {
5053 NESquit = !NESquit;
5054 zc_set_config(cfg_sect,"fastquit",(int32_t)NESquit);
5055 return D_O_K;
5056 }
5057
5058 int32_t onVolKeys()
5059 {
5060 volkeys = !volkeys;
5061 zc_set_config(sfx_sect,"volkeys",(int32_t)volkeys);
5062 return D_O_K;
5063 }
5064
5065 int32_t onShowFPS()
5066 {
5067 ShowFPS = !ShowFPS;
5068 zc_set_config(cfg_sect,"showfps",(int32_t)ShowFPS);
5069 return D_O_K;
5070 }
5071
5072 int32_t onShowTime()
5073 {
5074 ShowGameTime = !ShowGameTime;
5075 zc_set_config(cfg_sect,"showtime",ShowGameTime);
5076 return D_O_K;
5077 }
5078
5079 2161564474 bool is_Fkey(int32_t k)
5080 {
5081
2/2
✓ Branch 0 taken 219820116 times.
✓ Branch 1 taken 1941744358 times.
2161564474 switch(k)
5082 {
5083 case KEY_F1:
5084 case KEY_F2:
5085 case KEY_F3:
5086 case KEY_F4:
5087 case KEY_F5:
5088 case KEY_F6:
5089 case KEY_F7:
5090 case KEY_F8:
5091 case KEY_F9:
5092 case KEY_F10:
5093 case KEY_F11:
5094 case KEY_F12:
5095 219820116 return true;
5096 }
5097
5098 1941744358 return false;
5099 2161564474 }
5100
5101 void kb_getkey(DIALOG *d);
5102
5103 //Used by all keyboard key settings dialogues.
5104 void kb_clearjoystick(DIALOG *d)
5105 {
5106 d->flags|=D_SELECTED;
5107
5108 jwin_button_proc(MSG_DRAW,d,0);
5109 jwin_draw_win(screen, (screen->w-160)/2, (screen->h-48)/2, 160, 48, FR_WIN);
5110 // text_mode(vc(11));
5111 textout_centre_ex(screen, font, "Press any key to clear", gui_bmp->w/2, gui_bmp->h/2 - 8, jwin_pal[jcBOXFG],jwin_pal[jcBOX]);
5112 textout_centre_ex(screen, font, "ESC to cancel", gui_bmp->w/2, gui_bmp->h/2, jwin_pal[jcBOXFG],jwin_pal[jcBOX]);
5113
5114 update_hw_screen();
5115
5116 clear_keybuf();
5117 int32_t k = next_press_key();
5118 clear_keybuf();
5119
5120 //shnarf
5121 //47=f1
5122 //59=esc
5123 // if(k>0 && k<123 && !((k>46)&&(k<60)))
5124 // *((int32_t*)d->dp3) = k;
5125 if ( k != 59 ) *((int32_t*)d->dp3) = 0;
5126
5127
5128 d->flags&=~D_SELECTED;
5129 }
5130
5131 //Clears key to 0.
5132 //Used by all keyboard key settings dialogues.
5133 void kb_clearkey(DIALOG *d);
5134
5135 int32_t d_j_clearbutton_proc(int32_t msg,DIALOG *d,int32_t c)
5136 {
5137 switch(msg)
5138 {
5139 case MSG_KEY:
5140 case MSG_CLICK:
5141
5142 kb_clearjoystick(d);
5143
5144 while(gui_mouse_b())
5145 {
5146 clear_keybuf();
5147 rest(1);
5148 }
5149
5150 return D_REDRAW;
5151 }
5152
5153 return jwin_button_proc(msg,d,c);
5154 }
5155
5156 int32_t d_kbutton_proc(int32_t msg,DIALOG *d,int32_t c);
5157 //Only used in keyboard settings dialogues to clear keys.
5158 int32_t d_k_clearbutton_proc(int32_t msg,DIALOG *d,int32_t c);
5159
5160 int32_t j_getbtn(DIALOG *d)
5161 {
5162 d->flags|=D_SELECTED;
5163 jwin_button_proc(MSG_DRAW,d,0);
5164 jwin_draw_win(screen, (screen->w-160)/2, (screen->h-48)/2, 160, 48, FR_WIN);
5165 // text_mode(vc(11));
5166 int32_t y = screen->h/2 - 12;
5167 textout_centre_ex(screen, font, "Press a button", screen->w/2, y, jwin_pal[jcBOXFG],jwin_pal[jcBOX]);
5168 textout_centre_ex(screen, font, "ESC to cancel", screen->w/2, y+8, jwin_pal[jcBOXFG],jwin_pal[jcBOX]);
5169 textout_centre_ex(screen, font, "SPACE to disable", screen->w/2, y+16, jwin_pal[jcBOXFG],jwin_pal[jcBOX]);
5170
5171 update_hw_screen();
5172
5173 int32_t b = next_joy_input(true);
5174 if (b == -2)
5175 return D_CLOSE;
5176
5177 if(b>=0)
5178 *((int32_t*)d->dp3) = b;
5179
5180 d->flags&=~D_SELECTED;
5181
5182 return D_O_K;
5183 }
5184
5185 void j_getstick(DIALOG *d)
5186 {
5187 d->flags|=D_SELECTED;
5188 jwin_button_proc(MSG_DRAW,d,0);
5189 jwin_draw_win(screen, (screen->w-160)/2, (screen->h-48)/2, 160, 48, FR_WIN);
5190 // text_mode(vc(11));
5191 int32_t y = screen->h/2 - 12;
5192 textout_centre_ex(screen, font, "Move a stick (or DPAD)", screen->w/2, y, jwin_pal[jcBOXFG],jwin_pal[jcBOX]);
5193 textout_centre_ex(screen, font, "ESC to cancel", screen->w/2, y+8, jwin_pal[jcBOXFG],jwin_pal[jcBOX]);
5194 textout_centre_ex(screen, font, "SPACE to disable", screen->w/2, y+16, jwin_pal[jcBOXFG],jwin_pal[jcBOX]);
5195
5196 update_hw_screen();
5197
5198 int32_t b = next_joy_input(false);
5199
5200 if(b>=0)
5201 *((int32_t*)d->dp3) = b;
5202
5203 d->flags&=~D_SELECTED;
5204 }
5205
5206 int32_t d_jbutton_proc(int32_t msg,DIALOG *d,int32_t c)
5207 {
5208 switch(msg)
5209 {
5210 case MSG_KEY:
5211 case MSG_CLICK:
5212
5213 int ret = j_getbtn(d);
5214 if (ret != D_O_K)
5215 return ret;
5216
5217 while(gui_mouse_b()) {
5218 rest(1);
5219 clear_keybuf();
5220 }
5221
5222 return D_REDRAW;
5223 }
5224
5225 return jwin_button_proc(msg,d,c);
5226 }
5227
5228 int32_t d_jstick_proc(int32_t msg,DIALOG *d,int32_t c)
5229 {
5230 switch(msg)
5231 {
5232 case MSG_KEY:
5233 case MSG_CLICK:
5234
5235 j_getstick(d);
5236
5237 while(gui_mouse_b()) {
5238 rest(1);
5239 clear_keybuf();
5240 }
5241
5242 return D_REDRAW;
5243 }
5244
5245 return jwin_button_proc(msg,d,c);
5246 }
5247
5248 //shnarf
5249 extern const char *key_str[];
5250 std::string get_keystr(int key);
5251
5252 const char *pan_str[4] = { " MONO", " 1/2", " 3/4", " FULL" };
5253
5254 static char str_a[80],str_b[80],str_s[80],str_m[80],str_l[80],str_r[80],str_p[80],str_ex1[80],str_ex2[80],str_ex3[80],str_ex4[80],
5255 str_leftmod1[80],str_leftmod2[80],str_rightmod1[80],str_rightmod2[80], str_left[80], str_right[80], str_up[80], str_down[80],
5256 str_primary_stick[80], str_secondary_stick[80];
5257
5258 int32_t d_stringloader(int32_t msg,DIALOG *d,int32_t c)
5259 {
5260 //these are here to bypass compiler warnings about unused arguments
5261 c=c;
5262
5263 if (d->w == 1)
5264 {
5265 if (!gamepad_dlg_cur_joystick || !al_get_joystick_active(gamepad_dlg_cur_joystick))
5266 {
5267 InfoDialog("ZC", "Invalid gamepad. Did it disconnect?").show();
5268 return D_CLOSE;
5269 }
5270 }
5271
5272 if(msg==MSG_DRAW)
5273 {
5274 switch(d->w)
5275 {
5276 case 0:
5277 sprintf(str_a,"%03d\n%s",Akey,key_str[Akey]);
5278 sprintf(str_b,"%03d\n%s",Bkey,key_str[Bkey]);
5279 sprintf(str_s,"%03d\n%s",Skey,key_str[Skey]);
5280 sprintf(str_l,"%03d\n%s",Lkey,key_str[Lkey]);
5281 sprintf(str_r,"%03d\n%s",Rkey,key_str[Rkey]);
5282 sprintf(str_p,"%03d\n%s",Pkey,key_str[Pkey]);
5283 sprintf(str_ex1,"%03d\n%s",Exkey1,key_str[Exkey1]);
5284 sprintf(str_ex2,"%03d\n%s",Exkey2,key_str[Exkey2]);
5285 sprintf(str_ex3,"%03d\n%s",Exkey3,key_str[Exkey3]);
5286 sprintf(str_ex4,"%03d\n%s",Exkey4,key_str[Exkey4]);
5287 sprintf(str_up,"%03d\n%s",DUkey,key_str[DUkey]);
5288 sprintf(str_down,"%03d\n%s",DDkey,key_str[DDkey]);
5289 sprintf(str_left,"%03d\n%s",DLkey,key_str[DLkey]);
5290 sprintf(str_right,"%03d\n%s",DRkey,key_str[DRkey]);
5291 sprintf(str_leftmod1,"%03d\n%s",cheat_modifier_keys[0],key_str[cheat_modifier_keys[0]]);
5292 sprintf(str_leftmod2,"%03d\n%s",cheat_modifier_keys[1],key_str[cheat_modifier_keys[1]]);
5293 sprintf(str_rightmod1,"%03d\n%s",cheat_modifier_keys[2],key_str[cheat_modifier_keys[2]]);
5294 sprintf(str_rightmod2,"%03d\n%s",cheat_modifier_keys[3],key_str[cheat_modifier_keys[3]]);
5295 break;
5296
5297 case 1:
5298 sprintf(str_a,"%03d\n%s",Abtn,joybtn_name(Abtn));
5299 sprintf(str_b,"%03d\n%s",Bbtn,joybtn_name(Bbtn));
5300 sprintf(str_s,"%03d\n%s",Sbtn,joybtn_name(Sbtn));
5301 sprintf(str_l,"%03d\n%s",Lbtn,joybtn_name(Lbtn));
5302 sprintf(str_r,"%03d\n%s",Rbtn,joybtn_name(Rbtn));
5303 sprintf(str_m,"%03d\n%s",Mbtn,joybtn_name(Mbtn));
5304 sprintf(str_p,"%03d\n%s",Pbtn,joybtn_name(Pbtn));
5305 sprintf(str_ex1,"%03d\n%s",Exbtn1,joybtn_name(Exbtn1));
5306 sprintf(str_ex2,"%03d\n%s",Exbtn2,joybtn_name(Exbtn2));
5307 sprintf(str_ex3,"%03d\n%s",Exbtn3,joybtn_name(Exbtn3));
5308 sprintf(str_ex4,"%03d\n%s",Exbtn4,joybtn_name(Exbtn4));
5309 sprintf(str_up,"%03d\n%s",DUbtn,joybtn_name(DUbtn));
5310 sprintf(str_down,"%03d\n%s",DDbtn,joybtn_name(DDbtn));
5311 sprintf(str_left,"%03d\n%s",DLbtn,joybtn_name(DLbtn));
5312 sprintf(str_right,"%03d\n%s",DRbtn,joybtn_name(DRbtn));
5313 sprintf(str_primary_stick,"%03d\n%s",js_stick_1_x_stick,joystick_name(js_stick_1_x_stick));
5314 sprintf(str_secondary_stick,"%03d\n%s",js_stick_2_x_stick,joystick_name(js_stick_2_x_stick));
5315 sprintf(str_leftmod1,"%03d\n%s",cheat_modifier_keys[0],key_str[cheat_modifier_keys[0]]);
5316 sprintf(str_leftmod2,"%03d\n%s",cheat_modifier_keys[1],key_str[cheat_modifier_keys[1]]);
5317 sprintf(str_rightmod1,"%03d\n%s",cheat_modifier_keys[2],key_str[cheat_modifier_keys[2]]);
5318 sprintf(str_rightmod2,"%03d\n%s",cheat_modifier_keys[3],key_str[cheat_modifier_keys[3]]);
5319 break;
5320
5321 case 2:
5322 sprintf(str_a," %3d",midi_volume);
5323 sprintf(str_l," %3d",emusic_volume);
5324 sprintf(str_r," %3d",sfx_volume);
5325 strcpy(str_s,pan_str[pan_style]);
5326 sprintf(str_leftmod1,"%3d\n%s",cheat_modifier_keys[0],key_str[cheat_modifier_keys[0]]);
5327 sprintf(str_leftmod2,"%3d\n%s",cheat_modifier_keys[1],key_str[cheat_modifier_keys[1]]);
5328 sprintf(str_rightmod1,"%3d\n%s",cheat_modifier_keys[2],key_str[cheat_modifier_keys[2]]);
5329 sprintf(str_rightmod2,"%3d\n%s",cheat_modifier_keys[3],key_str[cheat_modifier_keys[3]]);
5330 break;
5331 }
5332 }
5333
5334 return D_O_K;
5335 }
5336
5337 int32_t set_vol(void *dp3, int32_t d2)
5338 {
5339 switch(((int32_t*)dp3)[0])
5340 {
5341 case 0:
5342 midi_volume = zc_min(d2<<3,255);
5343 break;
5344
5345 case 1:
5346 digi_volume = zc_min(d2<<3,255);
5347 break;
5348
5349 case 2:
5350 emusic_volume = zc_min(d2<<3,255);
5351 break;
5352
5353 case 3:
5354 sfx_volume = zc_min(d2<<3,255);
5355 break;
5356 }
5357
5358 // text_mode(vc(11));
5359 textprintf_right_ex(screen,get_zc_font(font_lfont_l), ((int32_t*)dp3)[1],((int32_t*)dp3)[2],jwin_pal[jcBOXFG],jwin_pal[jcBOX]," %3d",zc_min(d2<<3,255));
5360 return D_O_K;
5361 }
5362
5363 int32_t set_pan(void *dp3, int32_t d2)
5364 {
5365 pan_style = vbound(d2,0,3);
5366 // text_mode(vc(11));
5367 textout_right_ex(screen,get_zc_font(font_lfont_l), pan_str[pan_style],((int32_t*)dp3)[1],((int32_t*)dp3)[2],jwin_pal[jcBOXFG],jwin_pal[jcBOX]);
5368 return D_O_K;
5369 }
5370
5371 static int32_t gamepad_joys_list[] =
5372 {
5373 61,
5374 -1
5375 };
5376
5377 static int32_t gamepad_btn_list[] =
5378 {
5379 6,
5380 7,8,9,10,11,12,13,14,15,16,17,
5381 18,19,20,21,22,23,24,25,26,27,28,
5382 29,30,31,32,33,34,35,36,37,38,39,
5383 -1
5384 };
5385
5386 static int32_t gamepad_dirs_list[] =
5387 {
5388 40,41,42,43,
5389 44,45,46,47,
5390 48,49,50,51,
5391 52,53,54,55,
5392 56,57,58,59,
5393 60,
5394 -1
5395 };
5396
5397 static TABPANEL gamepad_tabs[] =
5398 {
5399 // (text)
5400 { (char *)"Controllers", D_SELECTED, gamepad_joys_list, 0, NULL },
5401 { (char *)"Buttons", 0, gamepad_btn_list, 0, NULL },
5402 { (char *)"Directions", 0, gamepad_dirs_list, 0, NULL },
5403 { NULL, 0, NULL, 0, NULL }
5404 };
5405
5406 const char *joy_list(int32_t index, int32_t *list_size)
5407 {
5408 if (index == -1)
5409 {
5410 *list_size = al_get_num_joysticks();
5411 return NULL;
5412 }
5413
5414 ALLEGRO_JOYSTICK* joy = al_get_joystick(index);
5415 if (!joy)
5416 {
5417 return "?";
5418 }
5419
5420 return al_get_joystick_name(joy);
5421 }
5422
5423 336 static ListData joy__list(joy_list, &font);
5424
5425 static int32_t d_joylist_proc(int32_t msg,DIALOG *d,int32_t c)
5426 {
5427 int32_t d2 = d->d2;
5428 int32_t ret = jwin_droplist_proc(msg,d,c);
5429
5430 if(d2!=d->d2)
5431 {
5432 joystick_index = d->d2;
5433 ret |= D_REDRAW_ALL;
5434 }
5435
5436 return ret;
5437 }
5438
5439 static DIALOG gamepad_dlg[] =
5440 {
5441 // (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp) (dp2) (dp3)
5442 { jwin_win_proc, 8, 24, 304, 256, 0, 0, 0, D_EXIT, 0, 0, (void *) "Gamepad Controls", NULL, NULL },
5443 { jwin_tab_proc, 8+4, 24+23,304-8,256-52,vc(0), vc(15), 0, 0, 0, 0, (void *) gamepad_tabs, NULL, (void *)gamepad_dlg },
5444 { d_stringloader, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
5445 { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
5446 { jwin_button_proc, 90, 254, 61, 21, 0, 0, 0, D_EXIT, 0, 0, (void *) "OK", NULL, NULL },
5447 { jwin_button_proc, 170, 254, 61, 21, 0, 0, 0, D_EXIT, 0, 0, (void *) "Cancel", NULL, NULL },
5448 // 6
5449 { d_dummy_proc, 14, 61, 294, 192, 0, 0, 0, 0, FR_ETCHED,0, NULL, NULL, NULL },
5450 // 7
5451 { jwin_ctext_proc, 92, 92-20, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_a, NULL, NULL },
5452 { jwin_ctext_proc, 92, 120-20, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_b, NULL, NULL },
5453 { jwin_ctext_proc, 92, 148-20, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_s, NULL, NULL },
5454 { jwin_ctext_proc, 92, 180-20, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_ex1, NULL, NULL },
5455 { jwin_ctext_proc, 92, 212-20, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_ex3, NULL, NULL },
5456 { jwin_ctext_proc, 237, 92-20, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_l, NULL, NULL },
5457 { jwin_ctext_proc, 237, 120-20, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_r, NULL, NULL },
5458 { jwin_ctext_proc, 237, 148-20, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_p, NULL, NULL },
5459 { jwin_ctext_proc, 237, 180-20, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_ex2, NULL, NULL },
5460 { jwin_ctext_proc, 237, 212-20, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_ex4, NULL, NULL },
5461 { jwin_ctext_proc, 92, 244-20, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_m, NULL, NULL },
5462 // 18
5463 { d_jbutton_proc, 22, 90-20, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "A", NULL, &Abtn},
5464 { d_jbutton_proc, 22, 118-20, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "B", NULL, &Bbtn},
5465 { d_jbutton_proc, 22, 146-20, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Start", NULL, &Sbtn},
5466 { d_jbutton_proc, 22, 178-20, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "X (EX1)", NULL, &Exbtn1},
5467 { d_jbutton_proc, 22, 210-20, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "EX3", NULL, &Exbtn3},
5468 { d_jbutton_proc, 167, 90-20, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "L", NULL, &Lbtn},
5469 { d_jbutton_proc, 167, 118-20, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "R", NULL, &Rbtn},
5470 { d_jbutton_proc, 167, 146-20, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Map", NULL, &Pbtn},
5471 { d_jbutton_proc, 167, 178-20, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Y (EX2)", NULL, &Exbtn2},
5472 { d_jbutton_proc, 167, 210-20, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "EX4", NULL, &Exbtn4},
5473 { d_jbutton_proc, 22, 242-20, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Menu", NULL, &Mbtn},
5474 // 29
5475 { d_j_clearbutton_proc, 22+91, 90-20, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Abtn},
5476 { d_j_clearbutton_proc, 22+91, 118-20, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Bbtn},
5477 { d_j_clearbutton_proc, 22+91, 146-20, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Sbtn},
5478 { d_j_clearbutton_proc, 22+91, 178-20, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Exbtn1},
5479 { d_j_clearbutton_proc, 22+91, 210-20, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Exbtn3},
5480 { d_j_clearbutton_proc, 167+91, 90-20, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Lbtn},
5481 { d_j_clearbutton_proc, 167+91, 118-20, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Rbtn},
5482 { d_j_clearbutton_proc, 167+91, 146-20, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Pbtn},
5483 { d_j_clearbutton_proc, 167+91, 178-20, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Exbtn2},
5484 { d_j_clearbutton_proc, 167+91, 210-20, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Exbtn4},
5485 { d_j_clearbutton_proc, 22+91, 242-20, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Mbtn},
5486 // 40
5487 { jwin_frame_proc, 14, 62, 147, 80, 0, 0, 0, 0, FR_ETCHED,0, NULL, NULL, NULL },
5488 { jwin_frame_proc, 159, 62, 147, 80, 0, 0, 0, 0, FR_ETCHED,0, NULL, NULL, NULL },
5489 { jwin_text_proc, 30, 68, 160, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Vertical", NULL, NULL },
5490 { jwin_text_proc, 175, 68, 160, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Horizontal", NULL, NULL },
5491 // 44
5492 { jwin_text_proc, 92, 84, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_up, NULL, NULL },
5493 { jwin_text_proc, 92, 112, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_down, NULL, NULL },
5494 { jwin_text_proc, 237, 84, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_left, NULL, NULL },
5495 { jwin_text_proc, 237, 112, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_right, NULL, NULL },
5496 // 48
5497 { d_jbutton_proc, 22, 82, 61, 21, vc(14), vc(11), 0, 0, 0, 0, (void *) "Up", NULL, &DUbtn },
5498 { d_jbutton_proc, 22, 110, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Down", NULL, &DDbtn },
5499 { d_jbutton_proc, 167, 82, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Left", NULL, &DLbtn },
5500 { d_jbutton_proc, 167, 110, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Right", NULL, &DRbtn },
5501 // 52
5502 { d_j_clearbutton_proc, 22+91, 82, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &DUbtn},
5503 { d_j_clearbutton_proc, 22+91, 110, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &DDbtn},
5504 { d_j_clearbutton_proc, 167+91, 82, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &DLbtn},
5505 { d_j_clearbutton_proc, 167+91, 110, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &DRbtn},
5506 // 56
5507 { jwin_check_proc, 22, 150, 147, 8, vc(14), vc(1), 0, 0, 1, 0, (void *) "Primary: Use Analog Stick (Ignore above and use below instead)", NULL, NULL },
5508 { d_jstick_proc, 22, 165, 61, 21, vc(14), vc(11), 0, 0, 0, 0, (void *) "Primary", NULL, &js_stick_1_x_stick },
5509 { d_jstick_proc, 22, 195, 61, 21, vc(14), vc(11), 0, 0, 0, 0, (void *) "Secondary", NULL, &js_stick_2_x_stick },
5510 { jwin_text_proc, 90, 165, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_primary_stick, NULL, NULL },
5511 { jwin_text_proc, 90, 195, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_secondary_stick, NULL, NULL },
5512
5513 // 61
5514 { d_joylist_proc, 22, 62, 150, 16, 0, 0, 0, 0, 0, 0, (void *) &joy__list, NULL, NULL },
5515
5516 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
5517 };
5518
5519 static int32_t keyboard_keys_list[] =
5520 {
5521 6,7,8,9,10,
5522 11,12,13,14,15,16,17,18,19,20,
5523 21,22,23,24,25,26,27,28,29,30,
5524 31,32,33,34,35,36,37,38,39,40,
5525 -1
5526 };
5527
5528 static int32_t keyboard_dirs_list[] =
5529 {
5530 41,42,43,44,
5531 45,46,47,48,
5532 49,50,51,52,
5533 53,54,55,56,
5534 -1
5535 };
5536
5537 static int32_t keyboard_mods_list[] =
5538 {
5539 57,58,59,60,
5540 61,62,63,64,
5541 65,66,67,68,
5542 69,70,71,72,
5543 -1
5544 };
5545
5546 static TABPANEL keyboard_control_tabs[] =
5547 {
5548 // (text)
5549 { (char *)"Keys", D_SELECTED, keyboard_keys_list, 0, NULL },
5550 { (char *)"Directions", 0, keyboard_dirs_list, 0, NULL },
5551 { (char *)"Cheat Mods", 0, keyboard_mods_list, 0, NULL },
5552 { NULL, 0, NULL, 0, NULL }
5553 };
5554
5555 static DIALOG keyboard_control_dlg[] =
5556 {
5557 // (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp) (dp2) (dp3)
5558 { jwin_win_proc, 8, 39, 304, 240, 0, 0, 0, D_EXIT, 0, 0, (void *) "Keyboard Controls", NULL, NULL },
5559 { jwin_tab_proc, 8+4, 39+23,304-8,240-56,vc(0), vc(15), 0, 0, 0, 0, (void *) keyboard_control_tabs, NULL, (void *)keyboard_control_dlg },
5560 { d_stringloader, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
5561 { jwin_button_proc, 90, 254, 61, 21, 0, 0, 0, D_EXIT, 0, 0, (void *) "OK", NULL, NULL },
5562 { jwin_button_proc, 170, 254, 61, 21, 0, 0, 0, D_EXIT, 0, 0, (void *) "Cancel", NULL, NULL },
5563 { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
5564 // Keys
5565 // 6
5566 { jwin_frame_proc, 14, 80, 148, 105, 0, 0, 0, 0, FR_ETCHED,0, NULL, NULL, NULL },
5567 { jwin_frame_proc, 158, 80, 148, 105, 0, 0, 0, 0, FR_ETCHED,0, NULL, NULL, NULL },
5568 { jwin_frame_proc, 14, 181, 292, 67, 0, 0, 0, 0, FR_ETCHED,0, NULL, NULL, NULL },
5569 { jwin_text_proc, 30, 86, 160, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Standard", NULL, NULL },
5570 { jwin_text_proc, 175, 86, 160, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Extended", NULL, NULL },
5571 // 11
5572 { jwin_text_proc, 92-4, 102, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_a, NULL, NULL },
5573 { jwin_text_proc, 92-4, 130, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_b, NULL, NULL },
5574 { jwin_text_proc, 92-4, 158, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_s, NULL, NULL },
5575 { jwin_text_proc, 92-4, 190, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_ex1, NULL, NULL },
5576 { jwin_text_proc, 92-4, 222, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_ex3, NULL, NULL },
5577 { jwin_text_proc, 237-4, 102, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_l, NULL, NULL },
5578 { jwin_text_proc, 237-4, 130, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_r, NULL, NULL },
5579 { jwin_text_proc, 237-4, 158, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_p, NULL, NULL },
5580 { jwin_text_proc, 237-4, 190, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_ex2, NULL, NULL },
5581 { jwin_text_proc, 237-4, 222, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_ex4, NULL, NULL },
5582 // 21
5583 { d_kbutton_proc, 22, 100, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "A", NULL, &Akey},
5584 { d_kbutton_proc, 22, 128, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "B", NULL, &Bkey},
5585 { d_kbutton_proc, 22, 156, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Start", NULL, &Skey},
5586 { d_kbutton_proc, 22, 188, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "X (EX1)", NULL, &Exkey1},
5587 { d_kbutton_proc, 22, 220, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "EX3", NULL, &Exkey3},
5588 { d_kbutton_proc, 167, 100, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "L", NULL, &Lkey},
5589 { d_kbutton_proc, 167, 128, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "R", NULL, &Rkey},
5590 { d_kbutton_proc, 167, 156, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Map", NULL, &Pkey},
5591 { d_kbutton_proc, 167, 188, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Y (EX2)", NULL, &Exkey2},
5592 { d_kbutton_proc, 167, 220, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "EX4", NULL, &Exkey4},
5593 // 31
5594 { d_k_clearbutton_proc, 22+91, 100, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Akey},
5595 { d_k_clearbutton_proc, 22+91, 128, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Bkey},
5596 { d_k_clearbutton_proc, 22+91, 156, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Skey},
5597 { d_k_clearbutton_proc, 22+91, 188, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Exkey1},
5598 { d_k_clearbutton_proc, 22+91, 220, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Exkey3},
5599 { d_k_clearbutton_proc, 167+91, 100, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Lkey},
5600 { d_k_clearbutton_proc, 167+91, 128, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Rkey},
5601 { d_k_clearbutton_proc, 167+91, 156, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Pkey},
5602 { d_k_clearbutton_proc, 167+91, 188, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Exkey2},
5603 { d_k_clearbutton_proc, 167+91, 220, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Exkey4},
5604 // Dirs
5605 // 41
5606 { jwin_frame_proc, 14, 80, 147, 80, 0, 0, 0, 0, FR_ETCHED,0, NULL, NULL, NULL },
5607 { jwin_frame_proc, 159, 80, 147, 80, 0, 0, 0, 0, FR_ETCHED,0, NULL, NULL, NULL },
5608 { jwin_text_proc, 30, 86, 160, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Vertical", NULL, NULL },
5609 { jwin_text_proc, 175, 86, 160, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Horizontal", NULL, NULL },
5610 // 45
5611 { jwin_text_proc, 92-4, 102, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_up, NULL, NULL },
5612 { jwin_text_proc, 92-4, 130, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_down, NULL, NULL },
5613 { jwin_text_proc, 237-4, 102, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_left, NULL, NULL },
5614 { jwin_text_proc, 237-4, 130, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_right, NULL, NULL },
5615 // 49
5616 { d_kbutton_proc, 22, 100, 61, 21, vc(14), vc(11), 0, 0, 0, 0, (void *) "Up", NULL, &DUkey},
5617 { d_kbutton_proc, 22, 128, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Down", NULL, &DDkey},
5618 { d_kbutton_proc, 167, 100, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Left", NULL, &DLkey},
5619 { d_kbutton_proc, 167, 128, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Right", NULL, &DRkey},
5620 // 53
5621 { d_k_clearbutton_proc, 22+91, 100, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &DUkey},
5622 { d_k_clearbutton_proc, 22+91, 128, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &DDkey},
5623 { d_k_clearbutton_proc, 167+91, 100, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &DLkey},
5624 { d_k_clearbutton_proc, 167+91, 128, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &DRkey},
5625 // Mods
5626 // 57
5627 { jwin_frame_proc, 14, 80, 148, 140-58, 0, 0, 0, 0, FR_ETCHED,0, NULL, NULL, NULL },
5628 { jwin_frame_proc, 158, 80, 148, 140-58, 0, 0, 0, 0, FR_ETCHED,0, NULL, NULL, NULL },
5629 { jwin_text_proc, 30, 86, 160, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Left", NULL, NULL },
5630 { jwin_text_proc, 175, 86, 160, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Right", NULL, NULL },
5631 // 61
5632 { jwin_text_proc, 92-26, 101, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_leftmod1, NULL, NULL },
5633 { jwin_text_proc, 92-26, 129, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_rightmod1, NULL, NULL },
5634 { jwin_text_proc, 237-4-22,101, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_leftmod2, NULL, NULL },
5635 { jwin_text_proc, 237-4-22,129, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_rightmod2, NULL, NULL },
5636 // 65
5637 { d_kbutton_proc, 22, 100, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Main", NULL, &cheat_modifier_keys[0]},
5638 { d_kbutton_proc, 22, 128, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Second", NULL, &cheat_modifier_keys[2]},
5639 { d_kbutton_proc, 167, 100, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Main", NULL, &cheat_modifier_keys[1]},
5640 { d_kbutton_proc, 167, 128, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Second", NULL, &cheat_modifier_keys[3]},
5641 // 69
5642 { d_k_clearbutton_proc, 22+91, 100, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &cheat_modifier_keys[0]},
5643 { d_k_clearbutton_proc, 22+91, 128, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &cheat_modifier_keys[2]},
5644 { d_k_clearbutton_proc, 167+91, 100, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &cheat_modifier_keys[1]},
5645 { d_k_clearbutton_proc, 167+91, 128, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &cheat_modifier_keys[3]},
5646 // 73
5647 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
5648 };
5649
5650 int32_t midi_dp[3] = {0,0,0};
5651 int32_t emus_dp[3] = {2,0,0};
5652 int32_t sfx_dp[3] = {3,0,0};
5653 int32_t pan_dp[3] = {0,0,0};
5654
5655 static DIALOG sound_dlg[] =
5656 {
5657 //(dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp) (dp2) (dp3)
5658 336 { jwin_win_proc, 0, 0, 320, 178, 0, 0, 0, D_EXIT, 0, 0, (void *) "Sound Settings", NULL, NULL },
5659 336 { d_stringloader, 0, 0, 2, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
5660 336 { jwin_button_proc, 58, 148, 61, 21, 0, 0, 0, D_EXIT, 0, 0, (void *) "OK", NULL, NULL },
5661 336 { jwin_button_proc, 138, 148, 61, 21, 0, 0, 0, D_EXIT, 0, 0, (void *) "Cancel", NULL, NULL },
5662 336 { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
5663 336 { jwin_frame_proc, 10, 28, 300, 112, 0, 0, 0, 0, FR_ETCHED, 0, NULL, NULL, NULL },
5664 336 { jwin_rtext_proc, 190, 40, 40, 8, vc(7), vc(11), 0, 0, 0, 0, (void *) str_a, NULL, NULL },
5665 336 { d_dummy_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
5666 336 { jwin_rtext_proc, 190, 56, 40, 8, vc(7), vc(11), 0, 0, 0, 0, (void *) str_l, NULL, NULL },
5667 336 { d_dummy_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
5668 // 10
5669 336 { jwin_rtext_proc, 190, 72, 40, 8, vc(7), vc(11), 0, 0, 0, 0, (void *) str_r, NULL, NULL },
5670 336 { jwin_rtext_proc, 190, 88, 40, 8, vc(7), vc(11), 0, 0, 0, 0, (void *) str_s, NULL, NULL },
5671 336 { d_dummy_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
5672 336 { d_dummy_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
5673 336 { d_dummy_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
5674 336 { jwin_slider_proc, 196, 40, 96, 8, vc(0), jwin_pal[jcBOX], 0, 0, 32, 0, NULL, (void *) set_vol, midi_dp },
5675 336 { d_dummy_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
5676 336 { jwin_slider_proc, 196, 56, 96, 8, vc(0), jwin_pal[jcBOX], 0, 0, 32, 0, NULL, (void *) set_vol, emus_dp },
5677 336 { d_dummy_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
5678 336 { jwin_slider_proc, 196, 72, 96, 8, vc(0), jwin_pal[jcBOX], 0, 0, 32, 0, NULL, (void *) set_vol, sfx_dp },
5679 //20
5680 336 { jwin_slider_proc, 196, 88, 96, 8, vc(0), jwin_pal[jcBOX], 0, 0, 3, 0, NULL, (void *) set_pan, pan_dp },
5681 336 { d_dummy_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
5682 336 { d_dummy_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
5683 336 { d_dummy_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
5684 336 { jwin_text_proc, 17, 40, 48, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "MIDI Volume", NULL, NULL },
5685 336 { jwin_text_proc, 17, 56, 48, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Music Volume (Enhanced Music)", NULL, NULL },
5686 336 { d_dummy_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
5687 336 { jwin_text_proc, 17, 72, 48, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "SFX Volume", NULL, NULL },
5688 336 { jwin_text_proc, 17, 88, 48, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "SFX Pan", NULL, NULL },
5689 336 { d_dummy_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
5690 //30
5691 336 { d_dummy_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
5692 336 { d_dummy_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
5693 336 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
5694 };
5695
5696 char zc_builddate[80];
5697 char zc_aboutstr[80];
5698
5699 static DIALOG about_dlg[] =
5700 {
5701 /* (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp) (dp2) (dp3) */
5702 { jwin_win_proc, 68, 52, 184, 154, 0, 0, 0, D_EXIT, 0, 0, (void *) "About", NULL, NULL },
5703 { jwin_button_proc, 140, 176, 41, 21, vc(14), 0, 0, D_EXIT, 0, 0, (void *) "OK", NULL, NULL },
5704 { jwin_ctext_proc, 160, 84, 0, 8, vc(0), vc(11), 0, 0, 0, 0, zc_aboutstr, NULL, NULL },
5705 { jwin_ctext_proc, 160, 92, 0, 8, vc(0) , vc(11), 0, 0, 0, 0, str_s, NULL, NULL },
5706 { jwin_ctext_proc, 160, 100, 0, 8, vc(0) , vc(11), 0, 0, 0, 0, zc_builddate, NULL, NULL },
5707 { jwin_text_proc, 88, 124, 140, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Coded by:", NULL, NULL },
5708 { jwin_text_proc, 88, 132, 140, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) " Phantom Menace", NULL, NULL },
5709 { jwin_text_proc, 88, 144, 140, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Produced by:", NULL, NULL },
5710 { jwin_text_proc, 88, 152, 140, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) " Armageddon Games", NULL, NULL },
5711 { jwin_frame_proc, 80, 117, 160, 50, 0, 0, 0, 0, FR_ETCHED,0, NULL, NULL, NULL },
5712 { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
5713 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
5714 };
5715
5716
5717 static DIALOG quest_dlg[] =
5718 {
5719 /* (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp) (dp2) (dp3) */
5720 { jwin_win_proc, 68, 25, 184, 190, 0, 0, 0, D_EXIT, 0, 0, (void *) "Quest Info", NULL, NULL },
5721 { jwin_edit_proc, 84, 54, 152, 16, 0, 0, 0, D_READONLY, 100, 0, NULL, NULL, NULL },
5722 { jwin_text_proc, 89, 84, 141, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Number:", NULL, NULL },
5723 { jwin_text_proc, 152, 84, 24, 8, vc(7), vc(11), 0, 0, 0, 0, str_a, NULL, NULL },
5724 { jwin_text_proc, 89, 94, 141, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Version:", NULL, NULL },
5725 { jwin_text_proc, 160, 94, 64, 8, vc(7), vc(11), 0, 0, 0, 0, header_version_nul_term, NULL, NULL },
5726 { jwin_text_proc, 89, 104, 141, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "ZQ Version:", NULL, NULL },
5727 { jwin_text_proc, 130, 104, 64, 8, vc(7), vc(11), 0, 0, 0, 0, str_s, NULL, NULL },
5728 { jwin_text_proc, 84, 126, 80, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Title:", NULL, NULL },
5729 { jwin_textbox_proc, 84, 136, 152, 24, 0, 0, 0, 0, 0, 0, QHeader.title, NULL, NULL },
5730 { jwin_text_proc, 84, 168, 80, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Author:", NULL, NULL },
5731 { jwin_textbox_proc, 84, 178, 152, 24, 0, 0, 0, 0, 0, 0, QHeader.author, NULL, NULL },
5732 { jwin_frame_proc, 84, 79, 152, 38, 0, 0, 0, 0, FR_ETCHED,0, NULL, NULL, NULL },
5733 { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
5734 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
5735 };
5736
5737 static DIALOG triforce_dlg[] =
5738 {
5739 /* (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp) */
5740 { jwin_win_proc, 72, 64, 177, 105, vc(14), vc(1), 0, D_EXIT, 0, 0, (void *) "Triforce Pieces", NULL, NULL },
5741 // 1
5742 { jwin_check_proc, 129, 94, 24, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "1", NULL, NULL },
5743 { jwin_check_proc, 129, 104, 24, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "2", NULL, NULL },
5744 { jwin_check_proc, 129, 114, 24, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "3", NULL, NULL },
5745 { jwin_check_proc, 129, 124, 24, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "4", NULL, NULL },
5746 { jwin_check_proc, 172, 94, 24, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "5", NULL, NULL },
5747 { jwin_check_proc, 172, 104, 24, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "6", NULL, NULL },
5748 { jwin_check_proc, 172, 114, 24, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "7", NULL, NULL },
5749 { jwin_check_proc, 172, 124, 24, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "8", NULL, NULL },
5750 // 9
5751 { jwin_button_proc, 90, 144, 61, 21, vc(0), vc(11), 'k', D_EXIT, 0, 0, (void *) "O&K", NULL, NULL },
5752 { jwin_button_proc, 170, 144, 61, 21, vc(0), vc(11), 27, D_EXIT, 0, 0, (void *) "Cancel", NULL, NULL },
5753 { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
5754 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
5755 };
5756
5757 int32_t onToggleRecordingNewSaves()
5758 {
5759 if (zc_get_config("zeldadx", "replay_new_saves", false))
5760 {
5761 zc_set_config("zeldadx", "replay_new_saves", false);
5762 }
5763 else
5764 {
5765 zc_set_config("zeldadx", "replay_new_saves", true);
5766 jwin_alert("Recording", "Newly created saves will be recorded and written to a replay file.",
5767 NULL,NULL,"OK",NULL,13,27,get_zc_font(font_lfont));
5768 }
5769 return D_O_K;
5770 }
5771
5772 #ifdef HAS_CURL
5773 int32_t onToggleAutoUploadReplays()
5774 {
5775 if (zc_get_config("zeldadx", "replay_upload", false))
5776 {
5777 zc_set_config("zeldadx", "replay_upload", false);
5778 }
5779 else
5780 {
5781 zc_set_config("zeldadx", "replay_upload", true);
5782 jwin_alert("Replays", "Replays will be automatically uploaded. This helps development by",
5783 " preventing bugs and simplifying bug reports.",
5784 "Upload will happen no more than once a week when closing ZC",
5785 "OK",NULL,13,27,get_zc_font(font_lfont));
5786
5787 if (!zc_get_config("zeldadx", "replay_new_saves", false))
5788 onToggleRecordingNewSaves();
5789 }
5790 return D_O_K;
5791 }
5792
5793 int32_t onUploadReplays()
5794 {
5795 if(jwin_alert3(
5796 "Upload replays",
5797 "Upload your replays now to assist in development?",
5798 NULL,
5799 NULL,
5800 "&Yes",
5801 "&No",
5802 NULL,
5803 'y',
5804 'n',
5805 0,
5806 get_zc_font(font_lfont)) == 1)
5807 {
5808 int num_uploaded = replay_upload();
5809 jwin_alert("Upload replays", fmt::format("Uploaded {} replays", num_uploaded).c_str(),
5810 NULL,NULL,"OK",NULL,13,27,get_zc_font(font_lfont));
5811 }
5812 return D_O_K;
5813 }
5814
5815 int32_t onClearUploadCache()
5816 {
5817 if(jwin_alert3(
5818 "Upload replays",
5819 "Clear the upload cache?",
5820 "This simply deletes replays/state.json. There's no harm in doing this, but",
5821 "likely is not necessary.",
5822 "&Yes",
5823 "&No",
5824 NULL,
5825 'y',
5826 'n',
5827 0,
5828 get_zc_font(font_lfont)) == 1)
5829 {
5830 replay_upload_clear_cache();
5831 }
5832 return D_O_K;
5833 }
5834 #endif
5835
5836 int32_t onToggleSnapshotAllFrames()
5837 {
5838 replay_set_snapshot_all_frames(!replay_is_snapshot_all_frames());
5839 return D_O_K;
5840 }
5841
5842 int32_t onStopReplayOrRecord()
5843 {
5844 if (replay_is_replaying())
5845 {
5846 replay_quit();
5847 }
5848 else if (replay_get_mode() == ReplayMode::Record)
5849 {
5850 if (!replay_get_meta_bool("test_mode"))
5851 {
5852 jwin_alert("Recording", "You cannot stop recording a save file.",
5853 NULL,NULL,"OK",NULL,13,27,get_zc_font(font_lfont));
5854 return D_CLOSE;
5855 }
5856
5857 if (jwin_alert("Stop Recording",
5858 "Save replay to disk and stop recording?",
5859 "This will stop the recording.",
5860 NULL,
5861 "Yes","No",13,27,get_zc_font(font_lfont)) != 1)
5862 return D_CLOSE;
5863
5864 replay_save();
5865 replay_stop();
5866 }
5867 return D_O_K;
5868 }
5869
5870 static int32_t handle_on_load_replay(ReplayMode mode)
5871 {
5872 bool ctrl = CHECK_CTRL_CMD;
5873 if (Playing)
5874 {
5875 if (jwin_alert("Replay - Warning!",
5876 "Loading a replay will exit the current game.",
5877 "All unsaved progress will be lost.",
5878 "Do you wish to continue?",
5879 "Yes","No",13,27,get_zc_font(font_lfont)) != 1)
5880 return D_CLOSE;
5881 }
5882
5883 std::string mode_string = replay_mode_to_string(mode);
5884 mode_string[0] = std::toupper(mode_string[0]);
5885
5886 std::string line_1 = "Select a replay file to play back.";
5887 std::string line_2 = "You won't be able to save, and it won't effect existing saves.";
5888 std::string line_3 = "You can stop the replay and take over manually any time.";
5889 if (mode == ReplayMode::Update)
5890 {
5891 line_1 = "Select a replay file to update.";
5892 line_2 = "WARNING: be sure to back up the zplay file";
5893 line_3 = "and verify that the updated replay works as expected!";
5894 }
5895
5896 if (jwin_alert(mode_string.c_str(),
5897 line_1.c_str(),
5898 line_2.c_str(),
5899 line_3.c_str(),
5900 "OK","Nevermind",13,27,get_zc_font(font_lfont)) == 1)
5901 {
5902 std::string replay_path = "replays/";
5903 if(ctrl && devpwd())
5904 replay_path = "../../tests/replays/";
5905 std::string prompt = fmt::format("Load Replay ({})", REPLAY_EXTENSION);
5906 if (auto result = prompt_for_existing_file(prompt, REPLAY_EXTENSION, nullptr, replay_path))
5907 replay_path = *result;
5908 else
5909 return D_CLOSE;
5910
5911 replay_quit();
5912 load_replay_file_deferred(mode, replay_path);
5913 Quit = qRESET;
5914 return D_CLOSE;
5915 }
5916 return D_O_K;
5917 }
5918
5919 int32_t onLoadReplay()
5920 {
5921 return handle_on_load_replay(ReplayMode::Replay);
5922 }
5923
5924 int32_t onLoadReplayAssert()
5925 {
5926 return handle_on_load_replay(ReplayMode::Assert);
5927 }
5928
5929 int32_t onLoadReplayUpdate()
5930 {
5931 return handle_on_load_replay(ReplayMode::Update);
5932 }
5933
5934 int32_t onSaveReplay()
5935 {
5936 if (replay_get_mode() == ReplayMode::Record)
5937 {
5938 if (!replay_get_meta_bool("test_mode"))
5939 {
5940 if (jwin_alert("Save Replay",
5941 "This will save a copy of the replay up to this point.",
5942 "The official replay file will be untouched.",
5943 "Do you wish to continue?",
5944 "Yes","No",13,27,get_zc_font(font_lfont)) != 1)
5945 {
5946 return D_CLOSE;
5947 }
5948
5949 std::string replay_path = replay_get_replay_path().string();
5950 std::string prompt = fmt::format("Save Replay ({})", REPLAY_EXTENSION);
5951 if (auto result = prompt_for_new_file(prompt, REPLAY_EXTENSION, nullptr, replay_path))
5952 replay_path = *result;
5953 else
5954 return D_CLOSE;
5955
5956 if (fileexists(replay_path.c_str()))
5957 {
5958 jwin_alert("Save Replay", "You cannot overwrite an existing file.",
5959 NULL,NULL,"OK",NULL,13,27,get_zc_font(font_lfont));
5960 return D_CLOSE;
5961 }
5962
5963 replay_save(replay_path);
5964 }
5965 else
5966 {
5967 replay_save();
5968 }
5969 }
5970 return D_O_K;
5971 }
5972
5973 enum
5974 {
5975 MENUID_REPLAY_RECORDNEW,
5976 MENUID_REPLAY_STOP,
5977 MENUID_REPLAY_SAVE,
5978 MENUID_REPLAY_SNAP_ALL,
5979 MENUID_REPLAY_AUTOUPLOAD,
5980 MENUID_REPLAY_UPLOAD,
5981 MENUID_REPLAY_CLEARUPLOADCACHE,
5982 };
5983
1/4
✓ Branch 0 taken 336 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
336 static NewMenu replay_menu
5984 4368 {
5985
2/4
✓ Branch 0 taken 336 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 336 times.
✗ Branch 3 not taken.
336 { "Record new saves", onToggleRecordingNewSaves, MENUID_REPLAY_RECORDNEW },
5986
2/4
✓ Branch 0 taken 336 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 336 times.
✗ Branch 3 not taken.
336 {},
5987
2/4
✓ Branch 0 taken 336 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 336 times.
✗ Branch 3 not taken.
336 { "Stop replay", onStopReplayOrRecord, MENUID_REPLAY_STOP },
5988
2/4
✓ Branch 0 taken 336 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 336 times.
✗ Branch 3 not taken.
336 { "Load replay", onLoadReplay },
5989
2/4
✓ Branch 0 taken 336 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 336 times.
✗ Branch 3 not taken.
336 { "Load replay (assert)", onLoadReplayAssert },
5990
2/4
✓ Branch 0 taken 336 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 336 times.
✗ Branch 3 not taken.
336 { "Load replay (update)", onLoadReplayUpdate },
5991
2/4
✓ Branch 0 taken 336 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 336 times.
✗ Branch 3 not taken.
336 { "Save replay", onSaveReplay, MENUID_REPLAY_SAVE },
5992
2/4
✓ Branch 0 taken 336 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 336 times.
✗ Branch 3 not taken.
336 { "Snapshot all frames", onToggleSnapshotAllFrames, MENUID_REPLAY_SNAP_ALL },
5993 #ifdef HAS_CURL
5994
2/4
✓ Branch 0 taken 336 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 336 times.
✗ Branch 3 not taken.
336 {},
5995
2/4
✓ Branch 0 taken 336 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 336 times.
✗ Branch 3 not taken.
336 { "Auto upload replays", onToggleAutoUploadReplays, MENUID_REPLAY_AUTOUPLOAD },
5996
2/4
✓ Branch 0 taken 336 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 336 times.
✗ Branch 3 not taken.
336 { "Upload replays", onUploadReplays, MENUID_REPLAY_UPLOAD },
5997
2/4
✓ Branch 0 taken 336 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 336 times.
✗ Branch 3 not taken.
336 { "Clear upload cache", onClearUploadCache, MENUID_REPLAY_CLEARUPLOADCACHE },
5998 #endif
5999 };
6000
6001 static DIALOG credits_dlg[] =
6002 {
6003 /* (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp) (dp2) (dp3) */
6004 { jwin_win_proc, 40, 38, 241, 173, vc(14), vc(1), 0, D_EXIT, 0, 0, (void *) "ZQuest Classic Credits", NULL, NULL },
6005 { jwin_frame_proc, 47, 65, 227, 115, vc(15), vc(1), 0, 0, FR_DEEP, 0, NULL, NULL, NULL },
6006 { d_bitmap_proc, 49, 67, 222, 110, vc(15), vc(1), 0, 0, 0, 0, NULL, NULL, NULL },
6007 { jwin_button_proc, 140, 184, 41, 21, vc(14), vc(1), 0, D_EXIT, 0, 0, (void *) "OK", NULL, NULL },
6008 { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
6009 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
6010 };
6011
6012 336 static ListData dmap_list(dmaplist, &font);
6013
6014 static DIALOG goto_dlg[] =
6015 {
6016 /* (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp) (dp2) (dp3) */
6017 { jwin_win_proc, 48, 25, 205, 100, 0, 0, 0, D_EXIT, 0, 0, (void *) "Goto Location", NULL, NULL },
6018 { jwin_button_proc, 90, 176-78, 61, 21, vc(14), 0, 13, D_EXIT, 0, 0, (void *) "OK", NULL, NULL },
6019 { jwin_button_proc, 170, 176-78, 61, 21, vc(14), 0, 27, D_EXIT, 0, 0, (void *) "Cancel", NULL, NULL },
6020 { jwin_text_proc, 55, 129-75, 80, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "DMap:", NULL, NULL },
6021 { jwin_droplist_proc, 88, 126-75, 160, 16, 0, 0, 0, 0, 0, 0, (void *) &dmap_list, NULL, NULL },
6022 { jwin_text_proc, 55, 149-75, 80, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Screen:", NULL, NULL },
6023 { jwin_edit_proc, 132, 146-75, 91, 16, 0, 0, 0, 0, 2, 0, NULL, NULL, NULL },
6024 { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
6025 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
6026 };
6027
6028 int32_t onGoTo()
6029 {
6030 bool music = false;
6031 music = music;
6032 sprintf(cheat_goto_screen_str,"%X",cheat_goto_screen);
6033
6034 goto_dlg[0].dp2=get_zc_font(font_lfont);
6035 goto_dlg[4].d2=cheat_goto_dmap;
6036 goto_dlg[6].dp=cheat_goto_screen_str;
6037
6038 clear_keybuf();
6039
6040 large_dialog(goto_dlg);
6041
6042 if(do_zqdialog(goto_dlg,4)==1)
6043 {
6044 int dmap = goto_dlg[4].d2;
6045 int screen = zc_xtoi(cheat_goto_screen_str);
6046 int adjusted_screen = screen + DMaps[dmap].xoff;
6047 if (adjusted_screen < 0 || adjusted_screen >= 128)
6048 {
6049 InfoDialog("Invalid screen", fmt::format("The screen {:02X} is out of bounds.", adjusted_screen)).show();
6050 }
6051 else
6052 {
6053 cheats_enqueue(Cheat::GoTo, dmap, screen);
6054 }
6055 };
6056
6057 return D_O_K;
6058 }
6059
6060 int32_t onGoToComplete()
6061 {
6062 if(!Playing)
6063 {
6064 return D_O_K;
6065 }
6066
6067 enter_sys_pal();
6068 music_pause();
6069 pause_all_sfx();
6070 onGoTo();
6071 eat_buttons();
6072
6073 zc_readrawkey(KEY_ESC);
6074
6075 exit_sys_pal();
6076 music_resume();
6077 resume_all_sfx();
6078 return D_O_K;
6079 }
6080
6081 int32_t onCredits()
6082 {
6083 return D_O_K;
6084 }
6085
6086 const char *midilist(int32_t index, int32_t *list_size)
6087 {
6088 if(index<0)
6089 {
6090 *list_size=0;
6091
6092 for(int32_t i=0; i<MAXMIDIS; i++)
6093 if(tunes[i].data)
6094 ++(*list_size);
6095
6096 return NULL;
6097 }
6098
6099 int32_t i=0,m=0;
6100
6101 while(m<=index && i<=MAXMIDIS)
6102 {
6103 if(tunes[i].data)
6104 ++m;
6105
6106 ++i;
6107 }
6108
6109 --i;
6110
6111 if(i==MAXMIDIS && m<index)
6112 return "(null)";
6113
6114 return tunes[i].title;
6115 }
6116
6117 /* ------- MIDI info stuff -------- */
6118
6119 char *text;
6120 midi_info *zmi;
6121 bool dialog_running;
6122 bool listening;
6123
6124 void get_info(int32_t index);
6125
6126 int32_t d_midilist_proc(int32_t msg,DIALOG *d,int32_t c)
6127 {
6128 int32_t d2 = d->d2;
6129 int32_t ret = jwin_droplist_proc(msg,d,c);
6130
6131 if(d2!=d->d2)
6132 {
6133 get_info(d->d2);
6134 }
6135
6136 return ret;
6137 }
6138
6139 int32_t d_listen_proc(int32_t msg,DIALOG *d,int32_t c)
6140 {
6141 /* 'd->d1' is offset from 'd' in DIALOG array to midilist proc */
6142
6143 int32_t ret = jwin_button_proc(msg,d,c);
6144
6145 if(ret == D_CLOSE)
6146 {
6147 // get current midi index
6148 int32_t index = (d+(d->d1))->d2;
6149 int32_t i=0, m=0;
6150
6151 while(m<=index && i<=MAXMIDIS)
6152 {
6153 if(tunes[i].data)
6154 ++m;
6155
6156 ++i;
6157 }
6158
6159 --i;
6160 jukebox(i);
6161 listening = true;
6162 ret = D_O_K;
6163 }
6164
6165 return ret;
6166 }
6167
6168 int32_t d_savemidi_proc(int32_t msg,DIALOG *d,int32_t c)
6169 {
6170 /* 'd->d1' is offset from 'd' in DIALOG array to midilist proc */
6171
6172 int32_t ret = jwin_button_proc(msg,d,c);
6173
6174 if(ret == D_CLOSE)
6175 {
6176 // get current midi index
6177 int32_t index = (d+(d->d1))->d2;
6178 int32_t i=0, m=0;
6179
6180 while(m<=index && i<=MAXMIDIS)
6181 {
6182 if(tunes[i].data)
6183 ++m;
6184
6185 ++i;
6186 }
6187
6188 --i;
6189
6190 char title[40] = "Save MIDI: ";
6191 static EXT_LIST list[] =
6192 {
6193 { (char *)"MIDI files (*.mid)", (char *)"mid" },
6194 { NULL, NULL }
6195 };
6196
6197 strcpy(title+11, tunes[i].title);
6198 title[39] = '\0';
6199
6200 std::string fname;
6201 if (auto result = prompt_for_new_file(title, "", list, "tune.mid"))
6202 fname = *result;
6203 else
6204 goto done;
6205
6206 if(exists(fname.c_str()))
6207 {
6208 if(jwin_alert(title, fname.c_str(), "already exists.", "Overwrite it?", "&Yes","&No",'y','n',get_zc_font(font_lfont))==2)
6209 goto done;
6210 }
6211
6212 // save midi i
6213
6214 if (save_midi(fname.c_str(), tunes[i].data) != 0)
6215 jwin_alert(title, "Error saving MIDI to", fname.c_str(), NULL, "Darn", NULL,13,27,get_zc_font(font_lfont));
6216
6217 done:
6218 chop_path(fname.data());
6219 ret = D_REDRAW;
6220 }
6221
6222 return ret;
6223 }
6224
6225 336 static ListData midi_list(midilist, &font);
6226
6227 static DIALOG midi_dlg[] =
6228 {
6229 /* (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp) (dp2) (dp3) */
6230 { jwin_win_proc, 8, 28, 304, 184, 0, 0, 0, D_EXIT, 0, 0, (void *) "MIDI Info", NULL, NULL },
6231 { jwin_text_proc, 32, 60, 40, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Tune:", NULL, NULL },
6232 { d_midilist_proc, 80, 56, 192, 16, 0, 0, 0, 0, 0, 0, (void *) &midi_list, NULL, NULL },
6233 { jwin_textbox_proc, 15, 80, 290, 96, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
6234 { d_listen_proc, 24, 183, 72, 21, 0, 0, 'l', D_EXIT, -2, 0, (void *) "&Listen", NULL, NULL },
6235 { d_savemidi_proc, 108, 183, 72, 21, 0, 0, 's', D_EXIT, -3, 0, (void *) "&Save", NULL, NULL },
6236 { jwin_button_proc, 236, 183, 61, 21, 0, 0, 'k', D_EXIT, 0, 0, (void *) "O&K", NULL, NULL },
6237 { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
6238 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
6239 };
6240
6241 void get_info(int32_t index)
6242 {
6243 int32_t i=0, m=0;
6244
6245 while(m<=index && i<=MAXMIDIS)
6246 {
6247 if(tunes[i].data)
6248 ++m;
6249
6250 ++i;
6251 }
6252
6253 --i;
6254
6255 if(i==MAXMIDIS && m<index)
6256 strcpy(text,"(null)");
6257 else
6258 {
6259 get_midi_info(tunes[i].data,zmi);
6260 get_midi_text(tunes[i].data,zmi,text);
6261 }
6262
6263 midi_dlg[0].dp2=get_zc_font(font_lfont);
6264 midi_dlg[3].dp = text;
6265 midi_dlg[3].d1 = midi_dlg[3].d2 = 0;
6266 midi_dlg[5].flags = (tunes[i].flags&tfDISABLESAVE) ? D_DISABLED : D_EXIT;
6267
6268 if(dialog_running)
6269 {
6270 jwin_textbox_proc(MSG_DRAW,midi_dlg+3,0);
6271 d_savemidi_proc(MSG_DRAW,midi_dlg+5,0);
6272 }
6273 }
6274
6275 int32_t onMIDICredits()
6276 {
6277 text = (char*)malloc(4096);
6278 zmi = (midi_info*)malloc(sizeof(midi_info));
6279
6280 if(!text || !zmi)
6281 {
6282 jwin_alert(NULL,"Not enough memory",NULL,NULL,"OK",NULL,13,27,get_zc_font(font_lfont));
6283 return D_O_K;
6284 }
6285
6286 bool do_pause_midi = midi_pos >= 0 && currmidi;
6287 auto restore_midi = currmidi;
6288 if(do_pause_midi)
6289 {
6290 paused_midi_pos = midi_pos;
6291 stop_midi();
6292 midi_suspended = midissuspHALTED;
6293 }
6294
6295 midi_dlg[0].dp2=get_zc_font(font_lfont);
6296 midi_dlg[2].d1 = 0;
6297 midi_dlg[2].d2 = 0;
6298 midi_dlg[4].flags = D_EXIT;
6299 midi_dlg[5].flags = (tunes[midi_dlg[2].d1].flags&tfDISABLESAVE) ? D_DISABLED : D_EXIT;
6300
6301 listening = false;
6302 dialog_running=false;
6303 get_info(0);
6304
6305 dialog_running=true;
6306
6307 large_dialog(midi_dlg);
6308
6309 do_zqdialog(midi_dlg,0);
6310 dialog_running=false;
6311
6312 if(listening)
6313 music_stop();
6314
6315 if(do_pause_midi)
6316 {
6317 // TODO: this probably doesn't resume midis nicely when scrolling (or in some other inner-gameloop).
6318 midi_suspended = midissuspRESUME;
6319 currmidi = restore_midi;
6320 midi_pos = paused_midi_pos;
6321 }
6322
6323 if(text) free(text);
6324 if(zmi) free(zmi);
6325 return D_O_K;
6326 }
6327
6328 int32_t onAbout()
6329 {
6330 char buf1[80]={0};
6331 std::ostringstream oss;
6332 sprintf(buf1,ZC_PLAYER_NAME);
6333 oss << buf1 << '\n';
6334 sprintf(buf1,"Version: %s", getVersionString());
6335 oss << buf1 << '\n';
6336 sprintf(buf1,"Build Date: %s %s, %d at @ %s %s", dayextension(BUILDTM_DAY).c_str(), (char*)months[BUILDTM_MONTH], BUILDTM_YEAR, __TIME__, __TIMEZONE__);
6337 oss << buf1 << '\n';
6338 sprintf(buf1, "Built By: %s", DEV_SIGNOFF);
6339 oss << buf1 << '\n';
6340
6341 InfoDialog("About ZC", oss.str()).show();
6342 return D_O_K;
6343 }
6344
6345 int32_t onQuest()
6346 {
6347 char fname[100];
6348 strcpy(fname, get_filename(qstpath));
6349 quest_dlg[0].dp2=get_zc_font(font_lfont);
6350 quest_dlg[1].dp = fname;
6351
6352 if(QHeader.quest_number==0)
6353 sprintf(str_a,"Custom");
6354 else
6355 sprintf(str_a,"%d",QHeader.quest_number);
6356
6357 sprintf(str_s,"%s",QHeader.getVerStr());
6358
6359 quest_dlg[11].d1 = quest_dlg[9].d1 = 0;
6360 quest_dlg[11].d2 = quest_dlg[9].d2 = 0;
6361
6362 large_dialog(quest_dlg);
6363
6364 do_zqdialog(quest_dlg, 0);
6365 return D_O_K;
6366 }
6367
6368 void call_vidmode_dlg();
6369 int32_t onVidMode()
6370 {
6371 call_vidmode_dlg();
6372 return D_O_K;
6373 }
6374
6375 #define addToHash(c,b,h) if(h->find(c ## key) == h->end()) \
6376 {(*h)[c ## key]=true;} else { if ( c ## key != 0 ) b = false;}
6377 //Added an extra statement, so that if the key is cleared to 0, the cleared
6378 //keybinding status need not be unique. -Z ( 1st April, 2019 )
6379
6380 void load_ukeys(int32_t* arr)
6381 {
6382 arr[ukey_a] = Akey;
6383 arr[ukey_b] = Bkey;
6384 arr[ukey_s] = Skey;
6385 arr[ukey_l] = Lkey;
6386 arr[ukey_r] = Rkey;
6387 arr[ukey_p] = Pkey;
6388 arr[ukey_ex1] = Exkey1;
6389 arr[ukey_ex2] = Exkey2;
6390 arr[ukey_ex3] = Exkey3;
6391 arr[ukey_ex4] = Exkey4;
6392 arr[ukey_du] = DUkey;
6393 arr[ukey_dd] = DDkey;
6394 arr[ukey_dl] = DLkey;
6395 arr[ukey_dr] = DRkey;
6396 arr[ukey_mod1a] = cheat_modifier_keys[0];
6397 arr[ukey_mod1b] = cheat_modifier_keys[1];
6398 arr[ukey_mod2a] = cheat_modifier_keys[2];
6399 arr[ukey_mod2b] = cheat_modifier_keys[3];
6400 };
6401
6402 static const char* ukey_names[] = {
6403 "A", "B", "Start", "L", "R", "Map",
6404 "Ex1", "Ex2", "Ex3", "Ex4", "Up", "Down",
6405 "Left", "Right", "Cheat Mod L1", "Cheat Mod L2",
6406 "Cheat Mod R1", "Cheat Mod R2",
6407 };
6408 std::string get_ukey_name(int32_t k)
6409 {
6410 if (k < num_ukey) return ukey_names[k];
6411 return "";
6412 }
6413
6414 int32_t onKeyboard()
6415 {
6416 int32_t a = Akey;
6417 int32_t b = Bkey;
6418 int32_t s = Skey;
6419 int32_t l = Lkey;
6420 int32_t r = Rkey;
6421 int32_t p = Pkey;
6422 int32_t ex1 = Exkey1;
6423 int32_t ex2 = Exkey2;
6424 int32_t ex3 = Exkey3;
6425 int32_t ex4 = Exkey4;
6426 int32_t du = DUkey;
6427 int32_t dd = DDkey;
6428 int32_t dl = DLkey;
6429 int32_t dr = DRkey;
6430 int32_t mod1a = cheat_modifier_keys[0];
6431 int32_t mod1b = cheat_modifier_keys[1];
6432 int32_t mod2a = cheat_modifier_keys[2];
6433 int32_t mod2b = cheat_modifier_keys[3];
6434 bool done=false;
6435 int32_t ret;
6436
6437 keyboard_control_dlg[0].dp2=get_zc_font(font_lfont);
6438
6439 large_dialog(keyboard_control_dlg);
6440
6441 while(!done)
6442 {
6443 ret = do_zqdialog(keyboard_control_dlg,3);
6444
6445 if(ret==3) // OK
6446 {
6447 int32_t ukeys[num_ukey];
6448 load_ukeys(ukeys);
6449 std::vector<std::string> uniqueError;
6450 for(int32_t q = 0; q < num_ukey; ++q)
6451 {
6452 for(int32_t p = q+1; p < num_ukey; ++p)
6453 {
6454 if(ukeys[q] == ukeys[p] && ukeys[q] != 0)
6455 {
6456 char buf[64];
6457 sprintf(buf, "'%s' conflicts with '%s'", get_ukey_name(q).c_str(), get_ukey_name(p).c_str());
6458 std::string str(buf);
6459 uniqueError.push_back(str);
6460 }
6461 }
6462 }
6463 if(uniqueError.size() == 0)
6464 {
6465 done = true;
6466 save_control_configs(true);
6467 }
6468 else
6469 {
6470 box_start(1, "Duplicate Keys", get_zc_font(font_lfont), get_zc_font(font_sfont), false, keyboard_control_dlg[0].w,keyboard_control_dlg[0].h, 2);
6471 box_out("Cannot have duplicate keybinds!"); box_eol();
6472 for(std::vector<std::string>::iterator it = uniqueError.begin();
6473 it != uniqueError.end(); ++it)
6474 {
6475 box_out((*it).c_str()); box_eol();
6476 }
6477 box_end(true);
6478 }
6479 }
6480 else // Cancel
6481 {
6482 Akey = a;
6483 Bkey = b;
6484 Skey = s;
6485 Lkey = l;
6486 Rkey = r;
6487 Pkey = p;
6488 Exkey1 = ex1;
6489 Exkey2 = ex2;
6490 Exkey3 = ex3;
6491 Exkey4 = ex4;
6492 DUkey = du;
6493 DDkey = dd;
6494 DLkey = dl;
6495 DRkey = dr;
6496 cheat_modifier_keys[0] = mod1a;
6497 cheat_modifier_keys[1] = mod1b;
6498 cheat_modifier_keys[2] = mod2a;
6499 cheat_modifier_keys[3] = mod2b;
6500
6501 done=true;
6502 }
6503
6504 rest(1);
6505 }
6506
6507 return D_O_K;
6508 }
6509
6510 int32_t onGamepad()
6511 {
6512 if (al_get_num_joysticks() == 0)
6513 {
6514 InfoDialog("ZC", "No gamepads detected.").show();
6515 return D_O_K;
6516 }
6517
6518 int32_t a = Abtn;
6519 int32_t b = Bbtn;
6520 int32_t s = Sbtn;
6521 int32_t l = Lbtn;
6522 int32_t r = Rbtn;
6523 int32_t m = Mbtn;
6524 int32_t p = Pbtn;
6525 int32_t ex1 = Exbtn1;
6526 int32_t ex2 = Exbtn2;
6527 int32_t ex3 = Exbtn3;
6528 int32_t ex4 = Exbtn4;
6529 int32_t up = DUbtn;
6530 int32_t down = DDbtn;
6531 int32_t left = DLbtn;
6532 int32_t right = DRbtn;
6533 int32_t joy = joystick_index;
6534 int32_t stick_1 = js_stick_1_x_stick;
6535 int32_t stick_2 = js_stick_2_x_stick;
6536
6537 gamepad_dlg[0].dp2=get_zc_font(font_lfont);
6538 if(analog_movement)
6539 gamepad_dlg[56].flags|=D_SELECTED;
6540 else
6541 gamepad_dlg[56].flags&=~D_SELECTED;
6542
6543 // TODO: should use controller device GUID or name instead of index, otherwise this value is not
6544 // consistent unless exact same number of joysticks is always connected. Name is problematic b/c
6545 // xinput driver doesn't actually get a name (at least, doesn't for my Xbox controller).
6546 // TODO: should store gamepad control mappings per-controller, otherwise switching joystick
6547 // requires remapping every time.
6548 if (joystick_index >= al_get_num_joysticks())
6549 joystick_index = 0;
6550 gamepad_dlg[61].d2 = joystick_index;
6551
6552 gamepad_dlg_cur_joystick = al_get_joystick(joystick_index);
6553 if (!gamepad_dlg_cur_joystick)
6554 {
6555 InfoDialog("ZC", "Invalid gamepad. Did it disconnect?").show();
6556 return D_CLOSE;
6557 }
6558
6559 large_dialog(gamepad_dlg);
6560
6561 int32_t ret = do_zqdialog(gamepad_dlg,4);
6562
6563 if(ret == 4) //OK
6564 {
6565 analog_movement = gamepad_dlg[56].flags&D_SELECTED;
6566 joystick_index = gamepad_dlg[61].d2;
6567 gamepad_dlg_cur_joystick = al_get_joystick(joystick_index);
6568 if (!gamepad_dlg_cur_joystick)
6569 {
6570 InfoDialog("ZC", "Invalid gamepad. Did it disconnect?").show();
6571 return D_CLOSE;
6572 }
6573 js_stick_1_y_stick = js_stick_1_x_stick;
6574 js_stick_2_y_stick = js_stick_2_x_stick;
6575 save_control_configs(false);
6576 }
6577 else //Cancel
6578 {
6579 Abtn = a;
6580 Bbtn = b;
6581 Sbtn = s;
6582 Lbtn = l;
6583 Rbtn = r;
6584 Mbtn = m;
6585 Pbtn = p;
6586 Exbtn1 = ex1;
6587 Exbtn2 = ex2;
6588 Exbtn3 = ex3;
6589 Exbtn4 = ex4;
6590 DUbtn = up;
6591 DDbtn = down;
6592 DLbtn = left;
6593 DRbtn = right;
6594 joystick_index = joy;
6595 js_stick_1_x_stick = stick_1;
6596 js_stick_2_x_stick = stick_2;
6597 }
6598
6599 return D_O_K;
6600 }
6601
6602 int32_t onCheatKeys()
6603 {
6604 int32_t oldcheats[Cheat::Last][2];
6605 memcpy(oldcheats, cheatkeys, sizeof(cheatkeys));
6606
6607 bool done=false;
6608
6609 while(!done)
6610 {
6611 bool confirm = false;
6612 CheatKeysDialog(&confirm).show();
6613 if(confirm) // OK
6614 {
6615 std::vector<std::string> uniqueError;
6616 char buf[512];
6617 for(size_t q = 1; q < Cheat::Last; ++q)
6618 {
6619 if(cheatkeys[q][1] && !cheatkeys[q][0])
6620 {
6621 cheatkeys[q][0] = cheatkeys[q][1];
6622 cheatkeys[q][1] = 0;
6623 }
6624 }
6625 for(size_t q = 1; q < Cheat::Last; ++q)
6626 {
6627 if(!bindable_cheat((Cheat)q)) continue;
6628 for(size_t p = q+1; p < Cheat::Last; ++p)
6629 {
6630 if(!bindable_cheat((Cheat)p)) continue;
6631 for(size_t q2 = 0; q2 <= 1; ++q2)
6632 for(size_t p2 = 0; p2 <= 1; ++p2)
6633 {
6634 if(cheatkeys[q][q2] == cheatkeys[p][p2] && cheatkeys[q][q2] != 0)
6635 {
6636 uniqueError.push_back(fmt::format("'{}' ({}) conflicts with '{}' ({}) - both '{}'",
6637 cheat_to_string((Cheat)q), q2?"Alt":"Main",
6638 cheat_to_string((Cheat)p), p2?"Alt":"Main",
6639 get_keystr(cheatkeys[q][q2])));
6640 }
6641 }
6642 }
6643 }
6644 if(uniqueError.size() == 0)
6645 {
6646 done = true;
6647 save_cheatkeys();
6648 }
6649 else
6650 {
6651 box_start(1, "Duplicate Keys", get_zc_font(font_lfont), get_zc_font(font_sfont), false, 500,400, 2);
6652 box_out("Cannot have duplicate keybinds!"); box_eol();
6653 for(std::vector<std::string>::iterator it = uniqueError.begin();
6654 it != uniqueError.end(); ++it)
6655 {
6656 box_out((*it).c_str()); box_eol();
6657 }
6658 box_end(true);
6659 }
6660 }
6661 else // Cancel
6662 {
6663 memcpy(cheatkeys, oldcheats, sizeof(cheatkeys));
6664 done=true;
6665 }
6666 rest(1);
6667 }
6668
6669 return D_O_K;
6670 }
6671
6672 int32_t onSound()
6673 {
6674 if (get_qr(qr_OLD_SCRIPT_VOLUME))
6675 {
6676 if (FFCore.coreflags & FFCORE_SCRIPTED_MIDI_VOLUME)
6677 {
6678 master_volume(-1, ((int32_t)FFCore.usr_midi_volume));
6679 }
6680 if (FFCore.coreflags & FFCORE_SCRIPTED_DIGI_VOLUME)
6681 {
6682 master_volume((int32_t)(FFCore.usr_digi_volume), 1);
6683 }
6684 if (FFCore.coreflags & FFCORE_SCRIPTED_MUSIC_VOLUME)
6685 {
6686 emusic_volume = (int32_t)FFCore.usr_music_volume;
6687 }
6688 if (FFCore.coreflags & FFCORE_SCRIPTED_SFX_VOLUME)
6689 {
6690 sfx_volume = (int32_t)FFCore.usr_sfx_volume;
6691 }
6692 }
6693 if ( FFCore.coreflags&FFCORE_SCRIPTED_PANSTYLE )
6694 {
6695 pan_style = (int32_t)FFCore.usr_panstyle;
6696 }
6697
6698 int32_t m = midi_volume;
6699 int32_t e = emusic_volume;
6700 int32_t s = sfx_volume;
6701 int32_t p = pan_style;
6702 pan_style = vbound(pan_style,0,3);
6703
6704 sound_dlg[0].dp2=get_zc_font(font_lfont);
6705
6706 large_dialog(sound_dlg);
6707
6708 midi_dp[1] = sound_dlg[6].x;
6709 midi_dp[2] = sound_dlg[6].y;
6710 emus_dp[1] = sound_dlg[8].x;
6711 emus_dp[2] = sound_dlg[8].y;
6712 sfx_dp[1] = sound_dlg[10].x;
6713 sfx_dp[2] = sound_dlg[10].y;
6714 pan_dp[1] = sound_dlg[11].x;
6715 pan_dp[2] = sound_dlg[11].y;
6716 sound_dlg[15].d2 = (midi_volume==255) ? 32 : midi_volume>>3;
6717 sound_dlg[17].d2 = (emusic_volume==255) ? 32 : emusic_volume>>3;
6718 sound_dlg[19].d2 = (sfx_volume==255) ? 32 : sfx_volume>>3;
6719 sound_dlg[20].d2 = pan_style;
6720
6721 int32_t ret = do_zqdialog(sound_dlg,1);
6722
6723 if(ret==2)
6724 {
6725 master_volume(digi_volume,midi_volume);
6726 if (zcmusic)
6727 zcmusic_set_volume(zcmusic, emusic_volume);
6728
6729 int32_t temp_volume = sfx_volume;
6730 if (GameLoaded && !get_qr(qr_OLD_SCRIPT_VOLUME))
6731 temp_volume = (sfx_volume * FFCore.usr_sfx_volume) / 10000 / 100;
6732 for(int32_t i=0; i<WAV_COUNT; ++i)
6733 {
6734 if(sfx_voice[i] >= 0)
6735 voice_set_volume(sfx_voice[i], temp_volume);
6736 }
6737 zc_set_config(sfx_sect,"midi",midi_volume);
6738 zc_set_config(sfx_sect,"sfx",sfx_volume);
6739 zc_set_config(sfx_sect,"emusic",emusic_volume);
6740 zc_set_config(sfx_sect,"pan",pan_style);
6741 }
6742 else
6743 {
6744 midi_volume = m;
6745 emusic_volume = e;
6746 sfx_volume = s;
6747 pan_style = p;
6748 }
6749
6750 return D_O_K;
6751 }
6752
6753 int32_t queding(char const* s1, char const* s2, char const* s3)
6754 {
6755 return jwin_alert("ZQuest Classic",s1,s2,s3,"&Yes","&No",'y','n',get_zc_font(font_lfont));
6756 }
6757
6758 int32_t onQuit()
6759 {
6760 if(Playing)
6761 {
6762 int32_t ret=0;
6763
6764 if(get_qr(qr_NOCONTINUE))
6765 {
6766 if(standalone_mode)
6767 {
6768 ret=queding("End current game?",
6769 "The continue screen is disabled; the game",
6770 "will be reloaded from the last save.");
6771 }
6772 else
6773 {
6774 ret=queding("End current game?",
6775 "The continue screen is disabled. You will",
6776 "be returned to the file select screen.");
6777 }
6778 }
6779 else
6780 ret=queding("End current game?",NULL,NULL);
6781
6782 if(ret==1)
6783 {
6784 disableClickToFreeze=false;
6785 Quit=qQUIT;
6786
6787 // Trying to evade a door repair charge?
6788 if(repaircharge)
6789 {
6790 game->change_drupy(-repaircharge);
6791 repaircharge=0;
6792 }
6793
6794 return D_CLOSE;
6795 }
6796 }
6797
6798 return D_O_K;
6799 }
6800
6801 int32_t onTryQuitMenu()
6802 {
6803 return onTryQuit(true);
6804 }
6805
6806 int32_t onTryQuit(bool inMenu)
6807 {
6808 if(Playing && !(GameFlags & GAMEFLAG_NO_F6))
6809 {
6810 if(active_cutscene.can_f6())
6811 {
6812 if(get_qr(qr_OLD_F6))
6813 {
6814 if(inMenu) onQuit();
6815 else /*if(!get_qr(qr_NOCONTINUE))*/ f_Quit(qQUIT);
6816 }
6817 else
6818 {
6819 disableClickToFreeze=false;
6820 GameFlags |= GAMEFLAG_TRYQUIT;
6821 }
6822 return D_CLOSE;
6823 }
6824 else active_cutscene.error();
6825 }
6826
6827 return D_O_K;
6828 }
6829
6830 int32_t onReset()
6831 {
6832 if(queding(" Reset system? ",NULL,NULL)==1)
6833 {
6834 disableClickToFreeze=false;
6835 Quit=qRESET;
6836 replay_quit();
6837 return D_CLOSE;
6838 }
6839
6840 return D_O_K;
6841 }
6842
6843 int32_t onExit()
6844 {
6845 if(queding(" Quit ZQuest Classic? ",NULL,NULL)==1)
6846 {
6847 Quit=qEXIT;
6848 return D_CLOSE;
6849 }
6850
6851 return D_O_K;
6852 }
6853
6854 int32_t onDebug()
6855 {
6856 if(debug_enabled)
6857 set_debug(!get_debug());
6858 return D_O_K;
6859 }
6860
6861 int32_t onHeartBeep()
6862 {
6863 heart_beep=!heart_beep;
6864 zc_set_config(cfg_sect,"heart_beep",heart_beep);
6865 return D_O_K;
6866 }
6867
6868 int32_t onSaveIndicator()
6869 {
6870 use_save_indicator = use_save_indicator ? 0 : 1;
6871 zc_set_config(cfg_sect,"save_indicator",use_save_indicator);
6872 return D_O_K;
6873 }
6874
6875 int32_t onEpilepsy()
6876 {
6877 if(jwin_alert3(
6878 "Epilepsy Flash Reduction",
6879 "Enabling this will reduce the intensity of flashing and screen wave effects.",
6880 "Disabling this will restore standard flash and wavy behaviour.",
6881 "Proceed?",
6882 "&Yes",
6883 "&No",
6884 NULL,
6885 'y',
6886 'n',
6887 0,
6888 get_zc_font(font_lfont)) == 1)
6889 {
6890 epilepsyFlashReduction = epilepsyFlashReduction ? 0 : 1;
6891 zc_set_config(cfg_sect,"epilepsy_flash_reduction",epilepsyFlashReduction);
6892 }
6893 return D_O_K;
6894 }
6895
6896 bool rc = false;
6897
6898 static DIALOG getnum_dlg[] =
6899 {
6900 // (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp)
6901 { jwin_win_proc, 80, 80, 160, 72, vc(0), vc(11), 0, D_EXIT, 0, 0, NULL, NULL, NULL },
6902 { jwin_text_proc, 104, 104+4, 48, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Number:", NULL, NULL },
6903 { jwin_edit_proc, 168, 104, 48, 16, 0, 0, 0, 0, 6, 0, NULL, NULL, NULL },
6904 { jwin_button_proc, 90, 126, 61, 21, vc(0), vc(11), 13, D_EXIT, 0, 0, (void *) "OK", NULL, NULL },
6905 { jwin_button_proc, 170, 126, 61, 21, vc(0), vc(11), 27, D_EXIT, 0, 0, (void *) "Cancel", NULL, NULL },
6906 { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
6907 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
6908 };
6909
6910 int32_t getnumber(const char *prompt,int32_t initialval)
6911 {
6912 char buf[20];
6913 sprintf(buf,"%d",initialval);
6914 getnum_dlg[0].dp=(void *)prompt;
6915 getnum_dlg[0].dp2=get_zc_font(font_lfont);
6916 getnum_dlg[2].dp=buf;
6917
6918 large_dialog(getnum_dlg);
6919
6920 if(do_zqdialog(getnum_dlg,2)==3)
6921 return atoi(buf);
6922
6923 return initialval;
6924 }
6925
6926 int32_t onLife()
6927 {
6928 int value = vbound(getnumber("Life",game->get_life()),1,game->get_maxlife());
6929 cheats_enqueue(Cheat::Life, value);
6930 return D_O_K;
6931 }
6932
6933 int32_t onHeartC()
6934 {
6935 int max_life = vbound(getnumber("Heart Containers",game->get_maxlife()/game->get_hp_per_heart()),1,4095) * game->get_hp_per_heart();
6936 int life = vbound(getnumber("Life",game->get_life()/game->get_hp_per_heart()),1,max_life/game->get_hp_per_heart())*game->get_hp_per_heart();
6937 cheats_enqueue(Cheat::MaxLife, max_life);
6938 cheats_enqueue(Cheat::Life, life);
6939 return D_O_K;
6940 }
6941
6942 int32_t onMagicC()
6943 {
6944 int max_magic = vbound(getnumber("Magic Containers",game->get_maxmagic()/game->get_mp_per_block()),0,2047) * game->get_mp_per_block();
6945 int magic = vbound(getnumber("Magic",game->get_magic()/game->get_mp_per_block()),0,max_magic/game->get_mp_per_block())*game->get_mp_per_block();
6946 cheats_enqueue(Cheat::MaxMagic, max_magic);
6947 cheats_enqueue(Cheat::Magic, magic);
6948 return D_O_K;
6949 }
6950
6951 int32_t onRupies()
6952 {
6953 int value = vbound(getnumber("Rupees",game->get_rupies()),0,game->get_maxcounter(1));
6954 cheats_enqueue(Cheat::Rupies, value);
6955 return D_O_K;
6956 }
6957
6958 int32_t onMaxBombs()
6959 {
6960 int value = vbound(getnumber("Max Bombs",game->get_maxbombs()),0,0xFFFF);
6961 cheats_enqueue(Cheat::MaxBombs, value);
6962 cheats_enqueue(Cheat::Bombs, value);
6963 return D_O_K;
6964 }
6965
6966 int32_t onRefillLife()
6967 {
6968 cheats_enqueue(Cheat::Life, game->get_maxlife());
6969 return D_O_K;
6970 }
6971 int32_t onRefillMagic()
6972 {
6973 cheats_enqueue(Cheat::Magic, game->get_maxmagic());
6974 return D_O_K;
6975 }
6976 int32_t onClock()
6977 {
6978 cheats_enqueue(Cheat::Clock);
6979 return D_O_K;
6980 }
6981
6982 int32_t onQstPath()
6983 {
6984 char initial_path[2048];
6985 chop_path(qstdir);
6986 strcpy(initial_path, qstdir);
6987
6988 if (auto result = prompt_for_existing_folder("Quest File Directory", initial_path, "qst"))
6989 {
6990 char* path = result->data();
6991 chop_path(path);
6992 fix_filename_case(path);
6993 fix_filename_slashes(path);
6994 strcpy(qstdir,path);
6995 strcpy(qstpath,qstdir);
6996 zc_set_config("zeldadx","quest_dir",qstdir);
6997 flush_config_file();
6998 }
6999
7000 return D_O_K;
7001 }
7002
7003 #include "dialog/cheat_dialog.h"
7004 int32_t onCheat()
7005 {
7006 call_setcheat_dialog();
7007 game->set_cheat(maxcheat);
7008 if(cheat) game->did_cheat(true);
7009 return D_O_K;
7010 }
7011
7012 int32_t onCheatRupies()
7013 {
7014 cheats_enqueue(Cheat::Rupies, game->get_maxcounter(1));
7015 return D_O_K;
7016 }
7017
7018 int32_t onCheatArrows()
7019 {
7020 cheats_enqueue(Cheat::Arrows, game->get_maxarrows());
7021 return D_O_K;
7022 }
7023
7024 int32_t onCheatBombs()
7025 {
7026 cheats_enqueue(Cheat::Bombs, game->get_maxbombs(), game->get_maxcounter(6));
7027 return D_O_K;
7028 }
7029
7030 // *** screen saver
7031
7032 18318343 int32_t after_time()
7033 {
7034
1/2
✓ Branch 0 taken 18318343 times.
✗ Branch 1 not taken.
18318343 if(ss_enable == 0)
7035 return INT_MAX;
7036
7037
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 18318343 times.
18318343 if(ss_after <= 0)
7038 return 5 * 60;
7039
7040
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 18318343 times.
18318343 if(ss_after <= 3)
7041 return ss_after * 15 * 60;
7042
7043
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 18318343 times.
18318343 if(ss_after <= 13)
7044 return (ss_after - 3) * 60 * 60;
7045
7046 18318343 return MAX_IDLE + 1;
7047 18318343 }
7048
7049 static const char *after_str[15] =
7050 {
7051 " 5 sec", "15 sec", "30 sec", "45 sec", " 1 min", " 2 min", " 3 min",
7052 " 4 min", " 5 min", " 6 min", " 7 min", " 8 min", " 9 min", "10 min",
7053 "Never"
7054 };
7055
7056 const char *after_list(int32_t index, int32_t *list_size)
7057 {
7058 if(index < 0)
7059 {
7060 *list_size = 15;
7061 return NULL;
7062 }
7063
7064 return after_str[index];
7065 }
7066
7067 336 static ListData after__list(after_list, &font);
7068
7069 static DIALOG scrsaver_dlg[] =
7070 {
7071 /* (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp) (dp2) (dp3) */
7072 336 { jwin_win_proc, 32, 64, 256, 136, 0, 0, 0, D_EXIT, 0, 0, (void *) "Screen Saver Settings", NULL, NULL },
7073 336 { jwin_frame_proc, 42, 92, 236, 70, 0, 0, 0, 0, FR_ETCHED,0, NULL, NULL, NULL },
7074 336 { jwin_text_proc, 60, 104, 48, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Run After", NULL, NULL },
7075 336 { jwin_text_proc, 60, 128, 48, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Speed", NULL, NULL },
7076 336 { jwin_text_proc, 60, 144, 48, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Density", NULL, NULL },
7077 336 { jwin_droplist_proc, 144, 100, 96, 16, 0, 0, 0, 0, 0, 0, (void *) &after__list, NULL, NULL },
7078 336 { jwin_slider_proc, 144, 128, 116, 8, vc(0), jwin_pal[jcBOX], 0, 0, 6, 0, NULL, NULL, NULL },
7079 336 { jwin_slider_proc, 144, 144, 116, 8, vc(0), jwin_pal[jcBOX], 0, 0, 6, 0, NULL, NULL, NULL },
7080 336 { jwin_button_proc, 42, 170, 61, 21, 0, 0, 0, D_EXIT, 0, 0, (void *) "OK", NULL, NULL },
7081 336 { jwin_button_proc, 124, 170, 72, 21, 0, 0, 0, D_EXIT, 0, 0, (void *) "Preview", NULL, NULL },
7082 336 { jwin_button_proc, 218, 170, 61, 21, 0, 0, 0, D_EXIT, 0, 0, (void *) "Cancel", NULL, NULL },
7083 336 { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
7084 336 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
7085 };
7086
7087 int32_t onScreenSaver()
7088 {
7089 scrsaver_dlg[0].dp2=get_zc_font(font_lfont);
7090 int32_t oldcfgs[3];
7091 scrsaver_dlg[5].d1 = scrsaver_dlg[5].d2 = oldcfgs[0] = ss_after;
7092 scrsaver_dlg[6].d2 = oldcfgs[1] = ss_speed;
7093 scrsaver_dlg[7].d2 = oldcfgs[2] = ss_density;
7094
7095 large_dialog(scrsaver_dlg);
7096
7097 int32_t ret = do_zqdialog(scrsaver_dlg,-1);
7098
7099 if(ret == 8 || ret == 9)
7100 {
7101 ss_after = scrsaver_dlg[5].d1;
7102 ss_speed = scrsaver_dlg[6].d2;
7103 ss_density = scrsaver_dlg[7].d2;
7104 if(oldcfgs[0] != ss_after)
7105 zc_set_config(cfg_sect,"ss_after",ss_after);
7106 if(oldcfgs[1] != ss_speed)
7107 zc_set_config(cfg_sect,"ss_speed",ss_speed);
7108 if(oldcfgs[2] != ss_density)
7109 zc_set_config(cfg_sect,"ss_density",ss_density);
7110 }
7111
7112 if(ret == 9)
7113 // preview Screen Saver
7114 {
7115 clear_keybuf();
7116 Matrix(ss_speed, ss_density, 30);
7117 system_pal(true);
7118 sys_mouse();
7119 }
7120
7121 return D_O_K;
7122 }
7123
7124 /***** Menus *****/
7125
7126 enum
7127 {
7128 MENUID_GAME_LOADQUEST,
7129 MENUID_GAME_ENDGAME,
7130 };
7131
1/4
✓ Branch 0 taken 336 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
336 static NewMenu game_menu
7132 2688 {
7133
3/6
✓ Branch 0 taken 336 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 336 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 336 times.
✗ Branch 5 not taken.
336 { "&Continue","ESC", onContinue },
7134
2/4
✓ Branch 0 taken 336 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 336 times.
✗ Branch 3 not taken.
336 {},
7135
2/4
✓ Branch 0 taken 336 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 336 times.
✗ Branch 3 not taken.
336 { "L&oad Quest...", onCustomGame, MENUID_GAME_LOADQUEST },
7136
3/6
✓ Branch 0 taken 336 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 336 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 336 times.
✗ Branch 5 not taken.
336 { "&End Game","F6", onTryQuitMenu, MENUID_GAME_ENDGAME },
7137
2/4
✓ Branch 0 taken 336 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 336 times.
✗ Branch 3 not taken.
336 {},
7138 #ifdef __EMSCRIPTEN__
7139 { "&Reset","F7", onReset },
7140 #elif defined(ALLEGRO_MACOSX)
7141 { "&Reset","F7", onReset },
7142 { "&Quit","F8", onExit },
7143 #else
7144
3/6
✓ Branch 0 taken 336 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 336 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 336 times.
✗ Branch 5 not taken.
336 { "&Reset","F9", onReset },
7145
3/6
✓ Branch 0 taken 336 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 336 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 336 times.
✗ Branch 5 not taken.
336 { "&Quit","F10", onExit },
7146 #endif
7147 };
7148
7149
1/4
✓ Branch 0 taken 336 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
336 static NewMenu snapshot_format_menu
7150 2352 {
7151
4/8
✓ Branch 0 taken 336 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 336 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 336 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 336 times.
✗ Branch 7 not taken.
336 { "&BMP", std::bind(onSetSnapshotFormat, ssfmtBMP) },
7152
4/8
✓ Branch 0 taken 336 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 336 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 336 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 336 times.
✗ Branch 7 not taken.
336 { "&GIF", std::bind(onSetSnapshotFormat, ssfmtGIF) },
7153
4/8
✓ Branch 0 taken 336 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 336 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 336 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 336 times.
✗ Branch 7 not taken.
336 { "&JPG", std::bind(onSetSnapshotFormat, ssfmtJPG) },
7154
4/8
✓ Branch 0 taken 336 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 336 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 336 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 336 times.
✗ Branch 7 not taken.
336 { "&PNG", std::bind(onSetSnapshotFormat, ssfmtPNG) },
7155
4/8
✓ Branch 0 taken 336 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 336 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 336 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 336 times.
✗ Branch 7 not taken.
336 { "PC&X", std::bind(onSetSnapshotFormat, ssfmtPCX) },
7156
4/8
✓ Branch 0 taken 336 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 336 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 336 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 336 times.
✗ Branch 7 not taken.
336 { "&TGA", std::bind(onSetSnapshotFormat, ssfmtTGA) },
7157 };
7158
7159
1/4
✓ Branch 0 taken 336 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
336 static NewMenu controls_menu
7160 1344 {
7161
2/4
✓ Branch 0 taken 336 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 336 times.
✗ Branch 3 not taken.
336 { "Key&board...", onKeyboard },
7162
2/4
✓ Branch 0 taken 336 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 336 times.
✗ Branch 3 not taken.
336 { "&Gamepad...", onGamepad },
7163
2/4
✓ Branch 0 taken 336 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 336 times.
✗ Branch 3 not taken.
336 { "&Cheat Keys...", onCheatKeys },
7164 };
7165
7166
1/4
✓ Branch 0 taken 336 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
336 static NewMenu name_entry_mode_menu
7167 1344 {
7168
2/4
✓ Branch 0 taken 336 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 336 times.
✗ Branch 3 not taken.
336 { "&Keyboard", onKeyboardEntry },
7169
2/4
✓ Branch 0 taken 336 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 336 times.
✗ Branch 3 not taken.
336 { "&Letter Grid", onLetterGridEntry },
7170
2/4
✓ Branch 0 taken 336 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 336 times.
✗ Branch 3 not taken.
336 { "&Extended Letter Grid", onExtLetterGridEntry },
7171 };
7172
7173 static void set_controls_menu_active()
7174 {
7175
7176 }
7177
7178 enum
7179 {
7180 MENUID_WINDOW_LOCK_ASPECT,
7181 MENUID_WINDOW_LOCK_INTSCALE,
7182 MENUID_WINDOW_SAVE_SIZE,
7183 MENUID_WINDOW_SAVE_POS,
7184 MENUID_WINDOW_STRETCH,
7185 };
7186
1/4
✓ Branch 0 taken 336 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
336 static NewMenu window_menu
7187 2016 {
7188
2/4
✓ Branch 0 taken 336 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 336 times.
✗ Branch 3 not taken.
336 { "Lock Aspect Ratio", onDragAspect, MENUID_WINDOW_LOCK_ASPECT },
7189
2/4
✓ Branch 0 taken 336 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 336 times.
✗ Branch 3 not taken.
336 { "Lock Integer Scale", onIntegerScaling, MENUID_WINDOW_LOCK_INTSCALE },
7190
2/4
✓ Branch 0 taken 336 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 336 times.
✗ Branch 3 not taken.
336 { "Save Size Changes", onSaveDragResize, MENUID_WINDOW_SAVE_SIZE },
7191
2/4
✓ Branch 0 taken 336 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 336 times.
✗ Branch 3 not taken.
336 { "Save Position Changes", onWinPosSave, MENUID_WINDOW_SAVE_POS },
7192
2/4
✓ Branch 0 taken 336 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 336 times.
✗ Branch 3 not taken.
336 { "Stretch Game Area", onStretchGame, MENUID_WINDOW_STRETCH },
7193 };
7194 void call_zc_options_dlg();
7195 enum
7196 {
7197 MENUID_OPTIONS_PAUSE_BG,
7198 MENUID_OPTIONS_EPILEPSYPROT,
7199 };
7200
1/4
✓ Branch 0 taken 336 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
336 static NewMenu options_menu
7201 2352 {
7202
2/4
✓ Branch 0 taken 336 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 336 times.
✗ Branch 3 not taken.
336 { "Name &Entry Mode", &name_entry_mode_menu },
7203
2/4
✓ Branch 0 taken 336 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 336 times.
✗ Branch 3 not taken.
336 { "S&napshot Format", &snapshot_format_menu },
7204
2/4
✓ Branch 0 taken 336 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 336 times.
✗ Branch 3 not taken.
336 { "&Window Settings", &window_menu },
7205
2/4
✓ Branch 0 taken 336 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 336 times.
✗ Branch 3 not taken.
336 { "Epilepsy Flash Reduction", onEpilepsy, MENUID_OPTIONS_EPILEPSYPROT },
7206
2/4
✓ Branch 0 taken 336 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 336 times.
✗ Branch 3 not taken.
336 { "Pause In Background", onPauseInBackground, MENUID_OPTIONS_PAUSE_BG },
7207
2/4
✓ Branch 0 taken 336 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 336 times.
✗ Branch 3 not taken.
336 { "More Options", call_zc_options_dlg },
7208 };
7209 enum
7210 {
7211 MENUID_SETTINGS_CONTROLS,
7212 MENUID_SETTINGS_CAPFPS,
7213 MENUID_SETTINGS_SHOWFPS,
7214 MENUID_SETTINGS_SHOWTIME,
7215 MENUID_SETTINGS_CLICK_FREEZE,
7216 MENUID_SETTINGS_TRANSLAYERS,
7217 MENUID_SETTINGS_NESQUIT,
7218 MENUID_SETTINGS_VOLKEYS,
7219 MENUID_SETTINGS_HEARTBEEP,
7220 MENUID_SETTINGS_SAVEINDICATOR,
7221 MENUID_SETTINGS_DEBUG,
7222 };
7223
1/4
✓ Branch 0 taken 336 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
336 static NewMenu settings_menu
7224 5712 {
7225
2/4
✓ Branch 0 taken 336 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 336 times.
✗ Branch 3 not taken.
336 { "&Sound...", onSound },
7226
2/4
✓ Branch 0 taken 336 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 336 times.
✗ Branch 3 not taken.
336 { "C&ontrols", &controls_menu, MENUID_SETTINGS_CONTROLS },
7227
2/4
✓ Branch 0 taken 336 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 336 times.
✗ Branch 3 not taken.
336 {},
7228
2/4
✓ Branch 0 taken 336 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 336 times.
✗ Branch 3 not taken.
336 { "Options", &options_menu },
7229
2/4
✓ Branch 0 taken 336 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 336 times.
✗ Branch 3 not taken.
336 {},
7230
3/6
✓ Branch 0 taken 336 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 336 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 336 times.
✗ Branch 5 not taken.
336 { "&Cap FPS","F1", onThrottleFPS, MENUID_SETTINGS_CAPFPS },
7231
3/6
✓ Branch 0 taken 336 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 336 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 336 times.
✗ Branch 5 not taken.
336 { "Show &FPS","F2", onShowFPS, MENUID_SETTINGS_SHOWFPS },
7232
2/4
✓ Branch 0 taken 336 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 336 times.
✗ Branch 3 not taken.
336 { "Show &Time", onShowTime, MENUID_SETTINGS_SHOWTIME },
7233
2/4
✓ Branch 0 taken 336 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 336 times.
✗ Branch 3 not taken.
336 { "Click to Freeze", onClickToFreeze, MENUID_SETTINGS_CLICK_FREEZE },
7234
2/4
✓ Branch 0 taken 336 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 336 times.
✗ Branch 3 not taken.
336 { "Cont. &Heart Beep", onHeartBeep, MENUID_SETTINGS_HEARTBEEP },
7235
2/4
✓ Branch 0 taken 336 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 336 times.
✗ Branch 3 not taken.
336 { "Show Trans. &Layers", onTransLayers, MENUID_SETTINGS_TRANSLAYERS },
7236
2/4
✓ Branch 0 taken 336 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 336 times.
✗ Branch 3 not taken.
336 { "Up+A+B To &Quit", onNESquit, MENUID_SETTINGS_NESQUIT },
7237
2/4
✓ Branch 0 taken 336 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 336 times.
✗ Branch 3 not taken.
336 { "Volume &Keys", onVolKeys, MENUID_SETTINGS_VOLKEYS },
7238
2/4
✓ Branch 0 taken 336 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 336 times.
✗ Branch 3 not taken.
336 { "Sa&ve Indicator", onSaveIndicator, MENUID_SETTINGS_SAVEINDICATOR },
7239
2/4
✓ Branch 0 taken 336 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 336 times.
✗ Branch 3 not taken.
336 {},
7240
2/4
✓ Branch 0 taken 336 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 336 times.
✗ Branch 3 not taken.
336 { "Debu&g", onDebug, MENUID_SETTINGS_DEBUG },
7241 };
7242
7243 enum
7244 {
7245 MENUID_MISC_FULLSCREEN,
7246 MENUID_MISC_VIDMODE,
7247 MENUID_MISC_QUEST_INFO,
7248 MENUID_MISC_QUEST_DIR,
7249 MENUID_MISC_CONSOLE,
7250 MENUID_MISC_CLEAR_CONSOLE_ON_LOAD,
7251 };
7252
1/4
✓ Branch 0 taken 336 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
336 static NewMenu misc_menu
7253 5040 {
7254
2/4
✓ Branch 0 taken 336 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 336 times.
✗ Branch 3 not taken.
336 { "&About...", onAbout },
7255 // TODO: re-enable, but: 1) do not use a bitmap thing that is hard to update 2) update names and 3) don't use the Z-word.
7256 // { "&Credits...", onCredits },
7257
2/4
✓ Branch 0 taken 336 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 336 times.
✗ Branch 3 not taken.
336 { "&Fullscreen", onFullscreenMenu, MENUID_MISC_FULLSCREEN },
7258
2/4
✓ Branch 0 taken 336 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 336 times.
✗ Branch 3 not taken.
336 { "&Video Mode...", onVidMode, MENUID_MISC_VIDMODE },
7259
2/4
✓ Branch 0 taken 336 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 336 times.
✗ Branch 3 not taken.
336 {},
7260
2/4
✓ Branch 0 taken 336 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 336 times.
✗ Branch 3 not taken.
336 { "&Quest Info...", onQuest, MENUID_MISC_QUEST_INFO },
7261
2/4
✓ Branch 0 taken 336 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 336 times.
✗ Branch 3 not taken.
336 { "Quest &MIDI Info...", onMIDICredits },
7262
2/4
✓ Branch 0 taken 336 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 336 times.
✗ Branch 3 not taken.
336 { "Quest &Directory...", onQstPath, MENUID_MISC_QUEST_DIR },
7263
2/4
✓ Branch 0 taken 336 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 336 times.
✗ Branch 3 not taken.
336 {},
7264
2/4
✓ Branch 0 taken 336 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 336 times.
✗ Branch 3 not taken.
336 { "Take &Snapshot F12", onSnapshot },
7265
2/4
✓ Branch 0 taken 336 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 336 times.
✗ Branch 3 not taken.
336 { "Sc&reen Saver...", onScreenSaver },
7266
2/4
✓ Branch 0 taken 336 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 336 times.
✗ Branch 3 not taken.
336 { "Save ZC Configuration", OnSaveZCConfig },
7267
2/4
✓ Branch 0 taken 336 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 336 times.
✗ Branch 3 not taken.
336 { "Show Console", onConsole, MENUID_MISC_CONSOLE },
7268
2/4
✓ Branch 0 taken 336 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 336 times.
✗ Branch 3 not taken.
336 { "Clear Console on Qst Load", onClrConsoleOnLoad, MENUID_MISC_CLEAR_CONSOLE_ON_LOAD },
7269
2/4
✓ Branch 0 taken 336 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 336 times.
✗ Branch 3 not taken.
336 { "Clear Directory Cache", OnnClearQuestDir },
7270 };
7271
7272 enum
7273 {
7274 MENUID_REFILL_ARROWS,
7275 };
7276
1/4
✓ Branch 0 taken 336 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
336 static NewMenu refill_menu
7277 2016 {
7278
2/4
✓ Branch 0 taken 336 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 336 times.
✗ Branch 3 not taken.
336 { "&Life", onRefillLife },
7279
2/4
✓ Branch 0 taken 336 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 336 times.
✗ Branch 3 not taken.
336 { "&Magic", onRefillMagic },
7280
2/4
✓ Branch 0 taken 336 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 336 times.
✗ Branch 3 not taken.
336 { "&Bombs", onCheatBombs },
7281
2/4
✓ Branch 0 taken 336 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 336 times.
✗ Branch 3 not taken.
336 { "&Rupees", onCheatRupies },
7282
2/4
✓ Branch 0 taken 336 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 336 times.
✗ Branch 3 not taken.
336 { "&Arrows", onCheatArrows, MENUID_REFILL_ARROWS },
7283 };
7284
7285 enum
7286 {
7287 MENUID_SHOW_L0,
7288 MENUID_SHOW_L1,
7289 MENUID_SHOW_L2,
7290 MENUID_SHOW_L3,
7291 MENUID_SHOW_L4,
7292 MENUID_SHOW_L5,
7293 MENUID_SHOW_L6,
7294 MENUID_SHOW_OVER,
7295 MENUID_SHOW_PUSH,
7296 MENUID_SHOW_FFC,
7297 MENUID_SHOW_SPR,
7298 MENUID_SHOW_SCRIPTNAME,
7299 MENUID_SHOW_SOLIDITY,
7300 MENUID_SHOW_HITBOX,
7301 MENUID_SHOW_EFFECT,
7302 };
7303
1/4
✓ Branch 0 taken 336 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
336 static NewMenu show_menu
7304 6384 {
7305
2/4
✓ Branch 0 taken 336 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 336 times.
✗ Branch 3 not taken.
336 { "Combos", onShowLayer0, MENUID_SHOW_L0 },
7306
2/4
✓ Branch 0 taken 336 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 336 times.
✗ Branch 3 not taken.
336 { "Layer 1", onShowLayer1, MENUID_SHOW_L1 },
7307
2/4
✓ Branch 0 taken 336 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 336 times.
✗ Branch 3 not taken.
336 { "Layer 2", onShowLayer2, MENUID_SHOW_L2 },
7308
2/4
✓ Branch 0 taken 336 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 336 times.
✗ Branch 3 not taken.
336 { "Layer 3", onShowLayer3, MENUID_SHOW_L3 },
7309
2/4
✓ Branch 0 taken 336 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 336 times.
✗ Branch 3 not taken.
336 { "Layer 4", onShowLayer4, MENUID_SHOW_L4 },
7310
2/4
✓ Branch 0 taken 336 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 336 times.
✗ Branch 3 not taken.
336 { "Layer 5", onShowLayer5, MENUID_SHOW_L5 },
7311
2/4
✓ Branch 0 taken 336 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 336 times.
✗ Branch 3 not taken.
336 { "Layer 6", onShowLayer6, MENUID_SHOW_L6 },
7312
2/4
✓ Branch 0 taken 336 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 336 times.
✗ Branch 3 not taken.
336 { "Overhead Combos", onShowLayerO, MENUID_SHOW_OVER },
7313
2/4
✓ Branch 0 taken 336 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 336 times.
✗ Branch 3 not taken.
336 { "Push Blocks", onShowLayerP, MENUID_SHOW_PUSH },
7314
2/4
✓ Branch 0 taken 336 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 336 times.
✗ Branch 3 not taken.
336 { "Freeform Combos", onShowLayerF, MENUID_SHOW_FFC },
7315
2/4
✓ Branch 0 taken 336 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 336 times.
✗ Branch 3 not taken.
336 { "Sprites", onShowLayerS, MENUID_SHOW_SPR },
7316
2/4
✓ Branch 0 taken 336 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 336 times.
✗ Branch 3 not taken.
336 {},
7317
2/4
✓ Branch 0 taken 336 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 336 times.
✗ Branch 3 not taken.
336 { "Current FFC Scripts", onShowFFScripts, MENUID_SHOW_SCRIPTNAME },
7318
2/4
✓ Branch 0 taken 336 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 336 times.
✗ Branch 3 not taken.
336 {},
7319
2/4
✓ Branch 0 taken 336 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 336 times.
✗ Branch 3 not taken.
336 { "Walkability", onShowLayerW, MENUID_SHOW_SOLIDITY },
7320
2/4
✓ Branch 0 taken 336 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 336 times.
✗ Branch 3 not taken.
336 { "Hitboxes", onShowHitboxes, MENUID_SHOW_HITBOX },
7321
2/4
✓ Branch 0 taken 336 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 336 times.
✗ Branch 3 not taken.
336 { "Effects", onShowLayerE, MENUID_SHOW_EFFECT },
7322
2/4
✓ Branch 0 taken 336 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 336 times.
✗ Branch 3 not taken.
336 { "Info Opacity", onShowInfoOpacity },
7323 };
7324
7325 enum
7326 {
7327 MENUID_CHEAT_CHOP_L1,
7328 MENUID_CHEAT_CHOP_L2,
7329 MENUID_CHEAT_CHOP_L3,
7330 MENUID_CHEAT_CHOP_L4,
7331 MENUID_CHEAT_INVULN,
7332 MENUID_CHEAT_NOCLIP,
7333 MENUID_CHEAT_IGNORESV,
7334 MENUID_CHEAT_GOFAST,
7335 };
7336
1/4
✓ Branch 0 taken 336 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
336 static NewMenu cheat_menu
7337 5712 {
7338
2/4
✓ Branch 0 taken 336 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 336 times.
✗ Branch 3 not taken.
336 { "Set &Cheat", onCheat },
7339
1/2
✓ Branch 0 taken 336 times.
✗ Branch 1 not taken.
336 { MENUID_CHEAT_CHOP_L1 },
7340
2/4
✓ Branch 0 taken 336 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 336 times.
✗ Branch 3 not taken.
336 { "Re&fill", &refill_menu },
7341
1/2
✓ Branch 0 taken 336 times.
✗ Branch 1 not taken.
336 { MENUID_CHEAT_CHOP_L2 },
7342
2/4
✓ Branch 0 taken 336 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 336 times.
✗ Branch 3 not taken.
336 { "&Invincible", onClock, MENUID_CHEAT_INVULN },
7343
2/4
✓ Branch 0 taken 336 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 336 times.
✗ Branch 3 not taken.
336 { "Ma&x Bombs...", onMaxBombs },
7344
2/4
✓ Branch 0 taken 336 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 336 times.
✗ Branch 3 not taken.
336 { "&Heart Containers...", onHeartC },
7345
2/4
✓ Branch 0 taken 336 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 336 times.
✗ Branch 3 not taken.
336 { "&Magic Containers...", onMagicC },
7346
1/2
✓ Branch 0 taken 336 times.
✗ Branch 1 not taken.
336 { MENUID_CHEAT_CHOP_L3 },
7347
2/4
✓ Branch 0 taken 336 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 336 times.
✗ Branch 3 not taken.
336 { "&Hero Data...", onCheatConsole },
7348
1/2
✓ Branch 0 taken 336 times.
✗ Branch 1 not taken.
336 { MENUID_CHEAT_CHOP_L4 },
7349
2/4
✓ Branch 0 taken 336 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 336 times.
✗ Branch 3 not taken.
336 { "Walk Through &Walls", onNoWalls, MENUID_CHEAT_NOCLIP },
7350
2/4
✓ Branch 0 taken 336 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 336 times.
✗ Branch 3 not taken.
336 { "Hero Ignores Side&view", onIgnoreSideview, MENUID_CHEAT_IGNORESV },
7351
2/4
✓ Branch 0 taken 336 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 336 times.
✗ Branch 3 not taken.
336 { "&Quick Movement", onGoFast, MENUID_CHEAT_GOFAST },
7352
2/4
✓ Branch 0 taken 336 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 336 times.
✗ Branch 3 not taken.
336 { "&Kill All Enemies", onKillCheat },
7353
2/4
✓ Branch 0 taken 336 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 336 times.
✗ Branch 3 not taken.
336 { "Trigger &Secrets", onSecretsCheat },
7354
2/4
✓ Branch 0 taken 336 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 336 times.
✗ Branch 3 not taken.
336 { "Trigger Secrets Perm", onSecretsCheatPerm },
7355
2/4
✓ Branch 0 taken 336 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 336 times.
✗ Branch 3 not taken.
336 { "Show/Hide Layer", &show_menu },
7356
2/4
✓ Branch 0 taken 336 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 336 times.
✗ Branch 3 not taken.
336 { "Toggle &Light", onLightSwitch },
7357
2/4
✓ Branch 0 taken 336 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 336 times.
✗ Branch 3 not taken.
336 { "&Goto Location...", onGoTo },
7358 };
7359
7360 #if DEVLEVEL > 0
7361 int32_t devLogging();
7362 int32_t devDebug();
7363 int32_t devTimestmp();
7364 #if DEVLEVEL > 1
7365 int32_t setCheat();
7366 #endif //DEVLEVEL > 1
7367 enum
7368 {
7369 MENUID_DEV_LOGGING,
7370 MENUID_DEV_DEBUG,
7371 MENUID_DEV_TIMESTAMP,
7372 MENUID_DEV_SETCHEAT,
7373 };
7374 static NewMenu dev_menu
7375 {
7376 { "&Force Error Log", devLogging, MENUID_DEV_LOGGING },
7377 // { "&Extra Debug Log", devDebug, MENUID_DEV_DEBUG },
7378 { "&Timestamp Log", devTimestmp, MENUID_DEV_TIMESTAMP },
7379 #if DEVLEVEL > 1
7380 {},
7381 { "Set &Cheat", setCheat, MENUID_DEV_SETCHEAT },
7382 #endif //DEVLEVEL > 1
7383 };
7384 int32_t devLogging()
7385 {
7386 dev_logging = !dev_logging;
7387 dev_menu.select_uid(MENUID_DEV_LOGGING, dev_logging);
7388 return D_O_K;
7389 }
7390 // int32_t devDebug()
7391 // {
7392 // dev_debug = !dev_debug;
7393 // dev_menu.select_uid(MENUID_DEV_DEBUG, dev_debug);
7394 // dev_menu[dv_dbg].flags = dev_debug ? D_SELECTED : 0;
7395 // return D_O_K;
7396 // }
7397 int32_t devTimestmp()
7398 {
7399 dev_timestmp = !dev_timestmp;
7400 dev_menu.select_uid(MENUID_DEV_TIMESTAMP, dev_timestmp);
7401 return D_O_K;
7402 }
7403 #if DEVLEVEL > 1
7404 int32_t setCheat()
7405 {
7406 cheat = (vbound(getnumber("Cheat Level",cheat), 0, 4));
7407 return D_O_K;
7408 }
7409 #endif //DEVLEVEL > 1
7410 #endif //DEVLEVEL > 0
7411
7412 enum
7413 {
7414 MENUID_PLAYER_CHEAT,
7415 };
7416
1/4
✓ Branch 0 taken 336 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
336 TopMenu the_player_menu
7417 2016 {
7418
2/4
✓ Branch 0 taken 336 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 336 times.
✗ Branch 3 not taken.
336 { "&Game", &game_menu },
7419
2/4
✓ Branch 0 taken 336 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 336 times.
✗ Branch 3 not taken.
336 { "&Settings", &settings_menu },
7420
2/4
✓ Branch 0 taken 336 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 336 times.
✗ Branch 3 not taken.
336 { "&Cheat", &cheat_menu, MENUID_PLAYER_CHEAT, true },
7421
2/4
✓ Branch 0 taken 336 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 336 times.
✗ Branch 3 not taken.
336 { "&Replay", &replay_menu },
7422
2/4
✓ Branch 0 taken 336 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 336 times.
✗ Branch 3 not taken.
336 { "&ZC", &misc_menu },
7423 #if DEVLEVEL > 0
7424 { "&Dev", &dev_menu },
7425 #endif
7426 };
7427
7428 int32_t onPauseInBackground()
7429 {
7430 if(jwin_alert3(
7431 "Toggle Pause In Background",
7432 "This action will change whether ZC Player pauses when the window loses focus.",
7433 "",
7434 "Proceed?",
7435 "&Yes",
7436 "&No",
7437 NULL,
7438 'y',
7439 'n',
7440 0,
7441 get_zc_font(font_lfont)) == 1)
7442 {
7443 pause_in_background = pause_in_background ? 0 : 1;
7444 zc_set_config("zeldadx","pause_in_background", pause_in_background);
7445 int switch_type = pause_in_background ? SWITCH_PAUSE : SWITCH_BACKGROUND;
7446 set_display_switch_mode(fullscreen?SWITCH_BACKAMNESIA:switch_type);
7447 set_display_switch_callback(SWITCH_OUT, switch_out_callback);
7448 set_display_switch_callback(SWITCH_IN, switch_in_callback);
7449 }
7450 options_menu.select_uid(MENUID_OPTIONS_PAUSE_BG, pause_in_background);
7451 return D_O_K;
7452 }
7453
7454 int32_t onKeyboardEntry()
7455 {
7456 NameEntryMode=0;
7457 zc_set_config(cfg_sect,"name_entry_mode",NameEntryMode);
7458 return D_O_K;
7459 }
7460
7461 int32_t onLetterGridEntry()
7462 {
7463 NameEntryMode=1;
7464 zc_set_config(cfg_sect,"name_entry_mode",NameEntryMode);
7465 return D_O_K;
7466 }
7467
7468 int32_t onExtLetterGridEntry()
7469 {
7470 NameEntryMode=2;
7471 zc_set_config(cfg_sect,"name_entry_mode",NameEntryMode);
7472 return D_O_K;
7473 }
7474
7475 static BITMAP* oldscreen;
7476 int32_t onFullscreenMenu()
7477 {
7478 PALETTE oldpal;
7479 get_palette(oldpal);
7480
7481 fullscreen = !fullscreen;
7482 all_toggle_fullscreen(fullscreen);
7483 zc_set_config("zeldadx","fullscreen",fullscreen);
7484
7485 zc_set_palette(oldpal);
7486 gui_mouse_focus=0;
7487 extern int32_t switch_type;
7488 switch_type = pause_in_background ? SWITCH_PAUSE : SWITCH_BACKGROUND;
7489 set_display_switch_mode(fullscreen?SWITCH_BACKAMNESIA:switch_type);
7490 set_display_switch_callback(SWITCH_OUT, switch_out_callback);
7491 set_display_switch_callback(SWITCH_IN, switch_in_callback);
7492 misc_menu.select_uid(MENUID_MISC_FULLSCREEN, isFullScreen());
7493 misc_menu.select_uid(MENUID_MISC_VIDMODE, isFullScreen());
7494
7495 return D_O_K;
7496 }
7497
7498 246 void fix_menu()
7499 {
7500
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 246 times.
246 if(!debug_enabled)
7501 246 settings_menu.chop_index = 13;
7502 246 }
7503
7504 int32_t onSetSnapshotFormat(SnapshotType format)
7505 {
7506 SnapshotFormat = format;
7507 zc_set_config("zeldadx", "snapshot_format", format);
7508 snapshot_format_menu.select_only_index(format);
7509 return D_O_K;
7510 }
7511
7512
7513 void color_layer(RGB *src,RGB *dest,char r,char g,char b,char pos,int32_t from,int32_t to)
7514 {
7515 PALETTE tmp;
7516
7517 for(int32_t i=0; i<256; i++)
7518 {
7519 tmp[i].r=r;
7520 tmp[i].g=g;
7521 tmp[i].b=b;
7522 }
7523
7524 fade_interpolate(src,tmp,dest,pos,from,to);
7525 }
7526
7527 55 void system_pal(bool force)
7528 {
7529
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 55 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
55 if(is_sys_pal && !force) return;
7530 55 is_sys_pal = true;
7531 55 load_colorset(gui_colorset, syspal, jwin_a5_colors);
7532 55 hw_palette = &syspal;
7533 55 update_hw_pal = true;
7534 55 }
7535
7536 static uint32_t entered_sys_pal = 0;
7537 55 void enter_sys_pal()
7538 {
7539
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 55 times.
55 if(is_sys_pal)
7540 {
7541 if(entered_sys_pal)
7542 ++entered_sys_pal;
7543 return;
7544 }
7545 55 sys_mouse();
7546 55 system_pal(true);
7547 55 ++entered_sys_pal;
7548 55 }
7549 55 void exit_sys_pal()
7550 {
7551
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 55 times.
55 if(entered_sys_pal)
7552 {
7553
1/2
✓ Branch 0 taken 55 times.
✗ Branch 1 not taken.
55 if(!--entered_sys_pal)
7554 {
7555 55 game_pal();
7556 55 game_mouse();
7557 55 }
7558 55 }
7559 55 }
7560
7561 void switch_out_callback()
7562 {
7563 if (pause_in_background && !MenuOpen)
7564 {
7565 System();
7566 }
7567 }
7568
7569 void switch_in_callback()
7570 {
7571 }
7572
7573 1080 void game_pal()
7574 {
7575 1080 is_sys_pal = false;
7576 1080 entered_sys_pal = 0;
7577 1080 hw_palette = &RAMpal;
7578 1080 update_hw_pal = true;
7579 1080 }
7580
7581 static char bar_str[] = "";
7582
7583 55 void music_pause()
7584 {
7585 //al_pause_duh(tmplayer);
7586 55 zcmusic_pause(zcmusic, ZCM_PAUSE);
7587
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 55 times.
55 if(zcmixer->oldtrack)
7588 zcmusic_pause(zcmixer->oldtrack, ZCM_PAUSE);
7589 55 zc_midi_pause();
7590 55 }
7591
7592 void music_resume()
7593 {
7594 //al_resume_duh(tmplayer);
7595 zcmusic_pause(zcmusic, ZCM_RESUME);
7596 if (zcmixer->oldtrack)
7597 zcmusic_pause(zcmixer->oldtrack, ZCM_RESUME);
7598 zc_midi_resume();
7599 }
7600
7601 7759 void music_stop()
7602 {
7603 //al_stop_duh(tmplayer);
7604 //unload_duh(tmusic);
7605 //tmusic=NULL;
7606 //tmplayer=NULL;
7607 7759 zcmusic_stop(zcmusic);
7608 7759 zcmusic_unload_file(zcmusic);
7609
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7759 times.
7759 if (zcmixer->oldtrack)
7610 {
7611 zcmusic_stop(zcmixer->oldtrack);
7612 zcmusic_unload_file(zcmixer->oldtrack);
7613 }
7614 7759 zcmixer->newtrack = NULL;
7615 7759 zc_stop_midi();
7616 7759 currmidi=-1;
7617 7759 }
7618
7619 bool reload_fonts = false;
7620 void System()
7621 {
7622 mouse_down = gui_mouse_b();
7623 music_pause();
7624 pause_all_sfx();
7625 MenuOpen = true;
7626 enter_sys_pal();
7627 // FONT *oldfont=font;
7628 // font=tfont;
7629
7630 misc_menu.select_uid(MENUID_MISC_FULLSCREEN, isFullScreen());
7631 misc_menu.disable_uid(MENUID_MISC_VIDMODE, isFullScreen());
7632
7633 #if DEVLEVEL > 1
7634 dev_menu.disable_uid(MENUID_DEV_SETCHEAT, !Playing);
7635 #endif
7636 game_menu.disable_uid(MENUID_GAME_LOADQUEST, get_unset_save_slot());
7637 game_menu.disable_uid(MENUID_GAME_ENDGAME, !Playing);
7638 misc_menu.disable_uid(MENUID_MISC_QUEST_INFO, !Playing);
7639 misc_menu.disable_uid(MENUID_MISC_QUEST_DIR, Playing);
7640 clear_keybuf();
7641
7642 clear_bitmap(menu_bmp);
7643 oldscreen = screen;
7644 screen = menu_bmp;
7645
7646 the_player_menu.reset_state();
7647 the_player_menu.position(0, 0);
7648
7649 bool running = true;
7650 bool esc = key[KEY_ESC] || cMbtn();
7651 bool autopop = esc;
7652 do
7653 {
7654 if(reload_fonts)
7655 {
7656 init_custom_fonts();
7657 clear_bitmap(menu_bmp);
7658 broadcast_dialog_message(MSG_DRAW, 0);
7659 reload_fonts = false;
7660 }
7661 if(handle_close_btn_quit())
7662 break;
7663
7664 //update submenus
7665 {
7666 settings_menu.disable_uid(MENUID_SETTINGS_CONTROLS, replay_is_replaying());
7667 settings_menu.select_uid(MENUID_SETTINGS_CAPFPS, Throttlefps);
7668 settings_menu.select_uid(MENUID_SETTINGS_SHOWFPS, ShowFPS);
7669 settings_menu.select_uid(MENUID_SETTINGS_SHOWTIME, ShowGameTime);
7670 settings_menu.select_uid(MENUID_SETTINGS_CLICK_FREEZE, ClickToFreeze);
7671 settings_menu.select_uid(MENUID_SETTINGS_TRANSLAYERS, TransLayers);
7672 settings_menu.select_uid(MENUID_SETTINGS_NESQUIT, NESquit);
7673 settings_menu.select_uid(MENUID_SETTINGS_VOLKEYS, volkeys);
7674
7675 window_menu.select_uid(MENUID_WINDOW_LOCK_ASPECT, DragAspect);
7676 window_menu.select_uid(MENUID_WINDOW_LOCK_INTSCALE, scaleForceInteger);
7677 window_menu.select_uid(MENUID_WINDOW_SAVE_SIZE, SaveDragResize);
7678 window_menu.select_uid(MENUID_WINDOW_SAVE_POS, SaveWinPos);
7679 window_menu.select_uid(MENUID_WINDOW_STRETCH, stretchGame);
7680
7681 options_menu.select_uid(MENUID_OPTIONS_EPILEPSYPROT, epilepsyFlashReduction);
7682 options_menu.select_uid(MENUID_OPTIONS_PAUSE_BG, pause_in_background);
7683
7684 name_entry_mode_menu.select_only_index(NameEntryMode);
7685
7686 misc_menu.select_uid(MENUID_MISC_CONSOLE, console_enabled);
7687 misc_menu.select_uid(MENUID_MISC_CLEAR_CONSOLE_ON_LOAD, clearConsoleOnLoad);
7688
7689 bool nocheat = (replay_is_replaying() || !Playing
7690 || (!maxcheat && !zcheats.flags && !get_debug() && DEVLEVEL < 2 && !zqtesting_mode && !devpwd()));
7691 the_player_menu.disable_uid(MENUID_PLAYER_CHEAT, nocheat);
7692 refill_menu.disable_uid(MENUID_REFILL_ARROWS, !get_qr(qr_TRUEARROWS));
7693 cheat_menu.chop_index.reset();
7694 if(cheat < 4)
7695 cheat_menu.chop_index = cheat_menu.ind_at(MENUID_CHEAT_CHOP_L1+cheat);
7696 cheat_menu.select_uid(MENUID_CHEAT_INVULN, getClock());
7697 cheat_menu.select_uid(MENUID_CHEAT_NOCLIP, toogam);
7698 cheat_menu.select_uid(MENUID_CHEAT_IGNORESV, ignoreSideview);
7699 cheat_menu.select_uid(MENUID_CHEAT_GOFAST, gofast);
7700
7701 show_menu.select_uid(MENUID_SHOW_L0, show_layer_0);
7702 show_menu.select_uid(MENUID_SHOW_L1, show_layer_1);
7703 show_menu.select_uid(MENUID_SHOW_L2, show_layer_2);
7704 show_menu.select_uid(MENUID_SHOW_L3, show_layer_3);
7705 show_menu.select_uid(MENUID_SHOW_L4, show_layer_4);
7706 show_menu.select_uid(MENUID_SHOW_L5, show_layer_5);
7707 show_menu.select_uid(MENUID_SHOW_L6, show_layer_6);
7708 show_menu.select_uid(MENUID_SHOW_OVER, show_layer_over);
7709 show_menu.select_uid(MENUID_SHOW_PUSH, show_layer_push);
7710 show_menu.select_uid(MENUID_SHOW_SPR, show_sprites);
7711 show_menu.select_uid(MENUID_SHOW_FFC, show_ffcs);
7712 show_menu.select_uid(MENUID_SHOW_SOLIDITY, show_walkflags);
7713 show_menu.select_uid(MENUID_SHOW_SCRIPTNAME, show_ff_scripts);
7714 show_menu.select_uid(MENUID_SHOW_HITBOX, show_hitboxes);
7715 show_menu.select_uid(MENUID_SHOW_EFFECT, show_effectflags);
7716
7717 settings_menu.select_uid(MENUID_SETTINGS_HEARTBEEP, heart_beep);
7718 settings_menu.select_uid(MENUID_SETTINGS_SAVEINDICATOR, use_save_indicator);
7719
7720 replay_menu.by_uid(MENUID_REPLAY_STOP)->text = fmt::format("Stop {}",
7721 replay_get_mode() == ReplayMode::Record ? "recording" : "replaying");
7722
7723 replay_menu.select_uid(MENUID_REPLAY_RECORDNEW, zc_get_config("zeldadx", "replay_new_saves", false));
7724 #ifdef HAS_CURL
7725 replay_menu.select_uid(MENUID_REPLAY_AUTOUPLOAD, replay_upload_auto_enabled());
7726 #endif
7727 replay_menu.disable_uid(MENUID_REPLAY_STOP, !replay_is_active());
7728 replay_menu.disable_uid(MENUID_REPLAY_SAVE, replay_get_mode() != ReplayMode::Record);
7729 replay_menu.select_uid(MENUID_REPLAY_SNAP_ALL, replay_is_snapshot_all_frames());
7730
7731 snapshot_format_menu.select_only_index(SnapshotFormat);
7732 }
7733
7734 if(debug_enabled)
7735 settings_menu.select_uid(MENUID_SETTINGS_DEBUG, get_debug());
7736
7737 if(autopop)
7738 clear_keybuf();
7739 the_player_menu.run(true);
7740 if(autopop)
7741 {
7742 the_player_menu.pop_sub(0, &the_player_menu);
7743 the_player_menu.draw(screen, the_player_menu.hovered_ind());
7744 autopop = false;
7745 update_hw_screen();
7746 }
7747
7748 update_hw_screen();
7749
7750 auto mb = gui_mouse_b();
7751 if(XOR(mb, mouse_down))
7752 {
7753 if(!the_player_menu.has_mouse())
7754 if(mb)
7755 break;
7756 mouse_down = mb;
7757 }
7758
7759 if(input_idle(true) > after_time())
7760 // run Screeen Saver
7761 {
7762 // Screen saver enabled for now.
7763 clear_keybuf();
7764 Matrix(ss_speed, ss_density, 0);
7765 system_pal(true);
7766 sys_mouse();
7767 }
7768
7769 poll_keyboard();
7770 if(esc)
7771 {
7772 if(!key[KEY_ESC])
7773 esc = false;
7774 }
7775
7776 if(keypressed() && !CHECK_ALT) //System hotkeys
7777 {
7778 auto c = peekkey();
7779 bool eatkey = true;
7780 switch(c>>8)
7781 {
7782 //Spare keys used by the menu
7783 case KEY_UP:
7784 case KEY_DOWN:
7785 case KEY_LEFT:
7786 case KEY_RIGHT:
7787 eatkey = false;
7788 break;
7789 case KEY_F1:
7790 onThrottleFPS();
7791 break;
7792 case KEY_F2:
7793 onShowFPS();
7794 break;
7795 case KEY_F6:
7796 onTryQuitMenu();
7797 break;
7798 #ifndef ALLEGRO_MACOSX
7799 case KEY_F9:
7800 onReset();
7801 break;
7802 case KEY_F10:
7803 onExit();
7804 break;
7805 #else
7806 case KEY_F7:
7807 onReset();
7808 break;
7809 case KEY_F8:
7810 onExit();
7811 break;
7812 #endif
7813 case KEY_F12:
7814 onSnapshot();
7815 break;
7816 case KEY_TAB:
7817 onDebug();
7818 break;
7819 case KEY_ESC:
7820 if(!esc)
7821 running = false;
7822 break;
7823 }
7824 if(eatkey)
7825 readkey();
7826 }
7827 if(Quit || (GameFlags & GAMEFLAG_TRYQUIT))
7828 break;
7829 }
7830 while(running);
7831
7832 screen = oldscreen;
7833
7834 mouse_down=gui_mouse_b();
7835 MenuOpen = false;
7836 if(Quit)
7837 {
7838 kill_sfx();
7839 music_stop();
7840 update_hw_screen();
7841 }
7842 else
7843 {
7844 music_resume();
7845 resume_all_sfx();
7846
7847 if(rc)
7848 ringcolor(false);
7849 }
7850 exit_sys_pal();
7851
7852 eat_buttons();
7853
7854 rc=false;
7855 clear_keybuf();
7856
7857 zc_init_apply_cheat_delta();
7858 }
7859
7860 246 void fix_dialogs()
7861 {
7862 246 jwin_center_dialog(about_dlg);
7863 246 jwin_center_dialog(gamepad_dlg);
7864 246 jwin_center_dialog(credits_dlg);
7865 246 jwin_center_dialog(gamemode_dlg);
7866 246 jwin_center_dialog(getnum_dlg);
7867 246 jwin_center_dialog(goto_dlg);
7868 246 jwin_center_dialog(keyboard_control_dlg);
7869 246 jwin_center_dialog(midi_dlg);
7870 246 jwin_center_dialog(quest_dlg);
7871 246 jwin_center_dialog(scrsaver_dlg);
7872 246 jwin_center_dialog(sound_dlg);
7873 246 jwin_center_dialog(triforce_dlg);
7874 246 }
7875
7876 4262 INLINE int32_t mixvol(int32_t v1,int32_t v2)
7877 {
7878
3/4
✓ Branch 0 taken 4262 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 4240 times.
✓ Branch 3 taken 22 times.
4262 return (zc_min(v1,255)*zc_min(v2,255)) >> 8;
7879 }
7880
7881 289 int32_t get_emusic_volume()
7882 {
7883 289 int32_t temp_volume = emusic_volume;
7884
2/4
✓ Branch 0 taken 289 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 289 times.
✗ Branch 3 not taken.
289 if (GameLoaded && !get_qr(qr_OLD_SCRIPT_VOLUME))
7885 temp_volume = (emusic_volume * FFCore.usr_music_volume) / 10000 / 100;
7886
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 289 times.
289 if (!zcmusic)
7887 289 return temp_volume;
7888 return (temp_volume * zcmusic->fadevolume) / 10000;
7889 289 }
7890
7891 int32_t get_zcmusicpos()
7892 {
7893 int32_t debugtracething = zcmusic_get_curpos(zcmusic);
7894 return debugtracething;
7895 return 0;
7896 }
7897
7898 void set_zcmusicpos(int32_t position)
7899 {
7900 zcmusic_set_curpos(zcmusic, position);
7901 }
7902
7903 void set_zcmusicspeed(int32_t speed)
7904 {
7905 zcmusic_set_speed(zcmusic, speed);
7906 }
7907
7908 int32_t get_zcmusiclen()
7909 {
7910 return zcmusic_get_length(zcmusic);
7911 }
7912
7913 3 void set_zcmusicloop(double start, double end)
7914 {
7915 3 zcmusic_set_loop(zcmusic, start, end);
7916 3 }
7917
7918 64156 void jukebox(int32_t index,int32_t loop)
7919 {
7920
1/2
✓ Branch 0 taken 64156 times.
✗ Branch 1 not taken.
64156 if (is_headless())
7921 64156 return;
7922
7923 music_stop();
7924
7925 if(index<0) index=MAXMIDIS-1;
7926
7927 if(index>=MAXMIDIS) index=0;
7928
7929 music_stop();
7930
7931 // Allegro's DIGMID driver (the one normally used on on Linux) gets
7932 // stuck notes when a song stops. This fixes it.
7933 if(strcmp(midi_driver->name, "DIGMID")==0)
7934 zc_set_volume(0, 0);
7935
7936 zc_set_volume(-1, mixvol(tunes[index].volume, midi_volume >>1));
7937 zc_play_midi(tunes[index].data,loop);
7938
7939 if(tunes[index].start>0)
7940 zc_midi_seek(tunes[index].start);
7941
7942 midi_loop_start = tunes[index].loop_start;
7943 midi_loop_end = tunes[index].loop_end;
7944
7945 currmidi=index;
7946 master_volume(digi_volume, midi_volume);
7947 //midi_paused=false;
7948 64156 }
7949
7950 64156 void jukebox(int32_t index)
7951 {
7952
1/2
✓ Branch 0 taken 64156 times.
✗ Branch 1 not taken.
64156 if(index<0) index=MAXMIDIS-1;
7953
7954
1/2
✓ Branch 0 taken 64156 times.
✗ Branch 1 not taken.
64156 if(index>=MAXMIDIS) index=0;
7955
7956 // do nothing if it's already playing
7957
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 64156 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
64156 if(index==currmidi && midi_pos>=0)
7958 {
7959 return;
7960 }
7961
7962 64156 jukebox(index,tunes[index].loop);
7963 64156 }
7964
7965 100 void play_DmapMusic()
7966 {
7967
1/2
✓ Branch 0 taken 100 times.
✗ Branch 1 not taken.
100 if (is_headless())
7968 100 return;
7969
7970 static char tfile[2048];
7971 static int32_t ttrack=0;
7972 bool domidi=false;
7973
7974 int32_t fadeoutframes = 0;
7975 if (zcmusic != NULL)
7976 fadeoutframes = zcmusic->fadeoutframes;
7977
7978 if(DMaps[currdmap].tmusic[0]!=0)
7979 {
7980 if(zcmusic==NULL ||
7981 strcmp(zcmusic->filename,DMaps[currdmap].tmusic)!=0 ||
7982 (zcmusic->type==ZCMF_GME && zcmusic->track != DMaps[currdmap].tmusictrack))
7983 {
7984 if (DMaps[currdmap].tmusic_xfade_in > 0 || fadeoutframes > 0)
7985 {
7986 if (play_enh_music_crossfade(DMaps[currdmap].tmusic, qstpath, DMaps[currdmap].tmusictrack, get_emusic_volume(), DMaps[currdmap].tmusic_xfade_in, fadeoutframes))
7987 {
7988 if (zcmusic != NULL)
7989 {
7990 zcmusic->fadeoutframes = DMaps[currdmap].tmusic_xfade_out;
7991 zcmusic_set_loop(zcmusic, double(DMaps[currdmap].tmusic_loop_start / 10000.0), double(DMaps[currdmap].tmusic_loop_end / 10000.0));
7992 }
7993 }
7994 }
7995 else
7996 {
7997 if (zcmusic != NULL)
7998 {
7999 zcmusic_stop(zcmusic);
8000 zcmusic_unload_file(zcmusic);
8001 zcmusic = NULL;
8002 zcmixer->newtrack = NULL;
8003 }
8004
8005 zcmusic = zcmusic_load_for_quest(DMaps[currdmap].tmusic, qstpath).first;
8006 zcmixer->newtrack = zcmusic;
8007
8008 if (zcmusic != NULL)
8009 {
8010 zc_stop_midi();
8011 strcpy(tfile, DMaps[currdmap].tmusic);
8012 zcmusic_play(zcmusic, emusic_volume);
8013 int32_t temptracks = 0;
8014 temptracks = zcmusic_get_tracks(zcmusic);
8015 temptracks = (temptracks < 2) ? 1 : temptracks;
8016 ttrack = vbound(DMaps[currdmap].tmusictrack, 0, temptracks - 1);
8017 zcmusic_change_track(zcmusic, ttrack);
8018 zcmusic_set_loop(zcmusic, double(DMaps[currdmap].tmusic_loop_start / 10000.0), double(DMaps[currdmap].tmusic_loop_end / 10000.0));
8019 }
8020 else
8021 {
8022 tfile[0] = 0;
8023 domidi = true;
8024 }
8025 }
8026 }
8027 }
8028 else
8029 {
8030 if (DMaps[currdmap].midi == 0 && fadeoutframes > 0 && zcmusic != NULL && strcmp(zcmusic->filename, DMaps[currdmap].tmusic) != 0)
8031 {
8032 play_enh_music_crossfade(NULL, qstpath, DMaps[currdmap].tmusictrack, get_emusic_volume(), DMaps[currdmap].tmusic_xfade_in, fadeoutframes);
8033 }
8034 else
8035 {
8036 domidi = true;
8037 }
8038 }
8039
8040 if(domidi)
8041 {
8042 int32_t m=DMaps[currdmap].midi;
8043
8044 switch(m)
8045 {
8046 case 1:
8047 jukebox(ZC_MIDI_OVERWORLD);
8048 break;
8049
8050 case 2:
8051 jukebox(ZC_MIDI_DUNGEON);
8052 break;
8053
8054 case 3:
8055 jukebox(ZC_MIDI_LEVEL9);
8056 break;
8057
8058 default:
8059 if(m>=4 && m<4+MAXCUSTOMMIDIS)
8060 jukebox(m+MIDIOFFSET_DMAP);
8061 else
8062 music_stop();
8063 }
8064 }
8065 100 }
8066
8067 34886 void playLevelMusic()
8068 {
8069
1/2
✓ Branch 0 taken 34886 times.
✗ Branch 1 not taken.
34886 if (is_headless())
8070 34886 return;
8071
8072 int32_t m=tmpscr->screen_midi;
8073
8074 switch(m)
8075 {
8076 case -2:
8077 music_stop();
8078 break;
8079
8080 case -1:
8081 play_DmapMusic();
8082 break;
8083
8084 case 1:
8085 jukebox(ZC_MIDI_OVERWORLD);
8086 break;
8087
8088 case 2:
8089 jukebox(ZC_MIDI_DUNGEON);
8090 break;
8091
8092 case 3:
8093 jukebox(ZC_MIDI_LEVEL9);
8094 break;
8095
8096 default:
8097 if(m>=4 && m<4+MAXCUSTOMMIDIS)
8098 jukebox(m+MIDIOFFSET_MAPSCR);
8099 else
8100 music_stop();
8101 }
8102 34886 }
8103
8104 4262 void master_volume(int32_t dv,int32_t mv)
8105 {
8106
7/8
✓ Branch 0 taken 2008 times.
✓ Branch 1 taken 2254 times.
✓ Branch 2 taken 1967 times.
✓ Branch 3 taken 287 times.
✓ Branch 4 taken 2254 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 1967 times.
✓ Branch 7 taken 287 times.
4262 if(dv>=0) digi_volume=zc_max(zc_min(dv,255),0);
8107
8108
7/8
✓ Branch 0 taken 2004 times.
✓ Branch 1 taken 2258 times.
✓ Branch 2 taken 2000 times.
✓ Branch 3 taken 258 times.
✓ Branch 4 taken 2258 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 2000 times.
✓ Branch 7 taken 258 times.
4262 if(mv>=0) midi_volume=zc_max(zc_min(mv,255),0);
8109
8110
3/6
✗ Branch 0 not taken.
✓ Branch 1 taken 4262 times.
✓ Branch 2 taken 4262 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 4262 times.
4262 int32_t i = zc_min(zc_max(currmidi,0),MAXMIDIS-1);
8111 4262 int32_t temp_vol = midi_volume;
8112
2/2
✓ Branch 0 taken 4016 times.
✓ Branch 1 taken 246 times.
4262 if (!get_qr(qr_OLD_SCRIPT_VOLUME))
8113 246 temp_vol = (midi_volume * FFCore.usr_music_volume) / 10000 / 100;
8114 4262 zc_set_volume(digi_volume,mixvol(tunes[i].volume, temp_vol));
8115 4262 }
8116
8117 // array of voices, one for each sfx sample in the data file
8118 // 0+ = voice #
8119 // -1 = voice not allocated
8120 246 void Z_init_sound()
8121 {
8122
2/2
✓ Branch 0 taken 62976 times.
✓ Branch 1 taken 246 times.
63222 for(int32_t i=0; i<WAV_COUNT; i++)
8123 62976 sfx_voice[i]=-1;
8124
8125 246 const char* midis[ZC_MIDI_COUNT] = {
8126 "assets/dungeon.mid",
8127 "assets/ending.mid",
8128 "assets/gameover.mid",
8129 "assets/level9.mid",
8130 "assets/overworld.mid",
8131 "assets/title.mid",
8132 "assets/triforce.mid",
8133 };
8134
2/2
✓ Branch 0 taken 1722 times.
✓ Branch 1 taken 246 times.
1968 for(int32_t i=0; i<ZC_MIDI_COUNT; i++)
8135 {
8136 1722 tunes[i].data = load_midi(midis[i]);
8137
1/2
✓ Branch 0 taken 1722 times.
✗ Branch 1 not taken.
1722 if (!tunes[i].data)
8138 Z_error_fatal("Missing required file %s\n", midis[i]);
8139 1722 }
8140
8141
2/2
✓ Branch 0 taken 61992 times.
✓ Branch 1 taken 246 times.
62238 for(int32_t j=0; j<MAXCUSTOMMIDIS; j++)
8142 61992 tunes[ZC_MIDI_COUNT+j].data=NULL;
8143
8144 246 master_volume(digi_volume,midi_volume);
8145 246 }
8146
8147 // returns number of voices currently allocated
8148 int32_t sfx_count()
8149 {
8150 int32_t c=0;
8151
8152 for(int32_t i=0; i<WAV_COUNT; i++)
8153 if(sfx_voice[i]!=-1)
8154 ++c;
8155
8156 return c;
8157 }
8158
8159 // clean up finished samples
8160 18109735 void sfx_cleanup()
8161 {
8162
2/2
✓ Branch 0 taken 4636092160 times.
✓ Branch 1 taken 18109735 times.
4654201895 for(int32_t i=0; i<WAV_COUNT; i++)
8163
3/4
✓ Branch 0 taken 1257775 times.
✓ Branch 1 taken 4634834385 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1257775 times.
4637349935 if(sfx_voice[i]!=-1 && voice_get_position(sfx_voice[i])<0)
8164 {
8165 1257775 deallocate_voice(sfx_voice[i]);
8166 1257775 sfx_voice[i]=-1;
8167 1257775 }
8168 18109735 }
8169
8170 1257912 SAMPLE* sfx_get_sample(int32_t index)
8171 {
8172 // check index
8173
2/4
✓ Branch 0 taken 1257912 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 1257912 times.
1257912 if (index<=0 || index>=WAV_COUNT)
8174 return nullptr;
8175
8176
2/2
✓ Branch 0 taken 446247 times.
✓ Branch 1 taken 811665 times.
1257912 if (sfxdat)
8177 {
8178
1/2
✓ Branch 0 taken 446247 times.
✗ Branch 1 not taken.
446247 if (index<Z35)
8179 {
8180 446247 return (SAMPLE*)sfxdata[index].dat;
8181 }
8182 else
8183 {
8184 return (SAMPLE*)sfxdata[Z35].dat;
8185 }
8186 }
8187 else
8188 {
8189 811665 return &customsfxdata[index];
8190 }
8191
8192 return nullptr;
8193 1257912 }
8194
8195 // allocates a voice for the sample "wav_index" (index into zelda.dat)
8196 // if a voice is already allocated (and/or playing), then it just returns true
8197 // Returns true: voice is allocated
8198 // false: unsuccessful
8199 1848912 bool sfx_init(int32_t index)
8200 {
8201 // check index
8202
3/4
✓ Branch 0 taken 1388740 times.
✓ Branch 1 taken 460172 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1388740 times.
1848912 if(index<=0 || index>=WAV_COUNT)
8203 460172 return false;
8204
8205
2/2
✓ Branch 0 taken 130874 times.
✓ Branch 1 taken 1257866 times.
1388740 if (sfx_voice[index] == -1)
8206 {
8207 1257866 SAMPLE* sample = sfx_get_sample(index);
8208
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1257866 times.
1257866 if (!sample)
8209 return false;
8210
8211 1257866 sfx_voice[index] = allocate_voice(sample);
8212 1257866 }
8213
8214 1388740 return sfx_voice[index] != -1;
8215 1848912 }
8216
8217 int32_t sfx_get_default_freq(int32_t index)
8218 {
8219 if (sfxdat)
8220 {
8221 if (index < Z35)
8222 {
8223 return ((SAMPLE*)sfxdata[index].dat)->freq;
8224 }
8225 else
8226 {
8227 return ((SAMPLE*)sfxdata[Z35].dat)->freq;
8228 }
8229 }
8230 else
8231 {
8232 return customsfxdata[index].freq;
8233 }
8234 }
8235
8236 int32_t sfx_get_length(int32_t index)
8237 {
8238 if (sfxdat)
8239 {
8240 if (index < Z35)
8241 {
8242 return int32_t(((SAMPLE*)sfxdata[index].dat)->len);
8243 }
8244 else
8245 {
8246 return int32_t(((SAMPLE*)sfxdata[Z35].dat)->len);
8247 }
8248 }
8249 else
8250 {
8251 return int32_t(customsfxdata[index].len);
8252 }
8253 }
8254
8255 // plays an sfx sample
8256 1848912 void sfx(int32_t index,int32_t pan,bool loop, bool restart, int32_t vol, int32_t freq)
8257 {
8258
2/2
✓ Branch 0 taken 1388740 times.
✓ Branch 1 taken 460172 times.
1848912 if(!sfx_init(index))
8259 460172 return;
8260
1/2
✓ Branch 0 taken 1388740 times.
✗ Branch 1 not taken.
1388740 if (!is_headless())
8261 {
8262 voice_set_playmode(sfx_voice[index], loop ? PLAYMODE_LOOP : PLAYMODE_PLAY);
8263 voice_set_pan(sfx_voice[index], pan);
8264
8265 // Only used by ZScript currently
8266 if (freq <= -1)
8267 {
8268 freq = sfx_get_default_freq(index);
8269 }
8270 voice_set_frequency(sfx_voice[index], freq);
8271
8272 // Only used by ZScript currently
8273 int32_t temp_volume = (sfx_volume * vol) / 10000 / 100;
8274 if (GameLoaded && !get_qr(qr_OLD_SCRIPT_VOLUME))
8275 temp_volume = (temp_volume * FFCore.usr_sfx_volume) / 10000 / 100;
8276 voice_set_volume(sfx_voice[index], temp_volume);
8277
8278 int32_t pos = voice_get_position(sfx_voice[index]);
8279
8280 if (restart) voice_set_position(sfx_voice[index], 0);
8281
8282 if (pos <= 0)
8283 voice_start(sfx_voice[index]);
8284 }
8285
8286
4/4
✓ Branch 0 taken 857521 times.
✓ Branch 1 taken 531219 times.
✓ Branch 2 taken 8 times.
✓ Branch 3 taken 857513 times.
1388740 if (restart && replay_is_debug())
8287 {
8288 // TODO: get rid of this bandaid next time replays are mass-updated.
8289 857513 const char* sfx_name = sfx_string[index];
8290
2/2
✓ Branch 0 taken 845806 times.
✓ Branch 1 taken 11707 times.
857513 if (strcmp(sfx_name, "Hero is hit") == 0)
8291 11707 sfx_name = "Player is hit";
8292
2/2
✓ Branch 0 taken 845684 times.
✓ Branch 1 taken 122 times.
845806 else if (strcmp(sfx_name, "Hero dies") == 0)
8293 122 sfx_name = "Player dies";
8294
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 857513 times.
857513 replay_step_comment(fmt::format("sfx {}", sfx_name));
8295 857513 }
8296 1848912 }
8297
8298 // true if sfx is allocated
8299 198761 bool sfx_allocated(int32_t index)
8300 {
8301
3/4
✓ Branch 0 taken 33450 times.
✓ Branch 1 taken 165311 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 33450 times.
198761 return (index>0 && index<WAV_COUNT && sfx_voice[index]!=-1);
8302 }
8303
8304 // start it (in loop mode) if it's not already playing,
8305 // otherwise adjust it to play in loop mode -DD
8306 117025 void cont_sfx(int32_t index)
8307 {
8308
1/2
✓ Branch 0 taken 117025 times.
✗ Branch 1 not taken.
117025 if (is_headless())
8309 117025 return;
8310
8311 if(!sfx_init(index))
8312 {
8313 return;
8314 }
8315
8316 if(voice_get_position(sfx_voice[index])<=0)
8317 {
8318 voice_set_position(sfx_voice[index],0);
8319 voice_set_playmode(sfx_voice[index],PLAYMODE_LOOP);
8320 voice_set_volume(sfx_voice[index], sfx_volume);
8321 voice_start(sfx_voice[index]);
8322 }
8323 else
8324 {
8325 adjust_sfx(index, 128, true);
8326 }
8327 117025 }
8328
8329 // adjust parameters while playing
8330 4903 void adjust_sfx(int32_t index,int32_t pan,bool loop)
8331 {
8332
4/6
✓ Branch 0 taken 4467 times.
✓ Branch 1 taken 436 times.
✓ Branch 2 taken 4467 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 4467 times.
4903 if(index<=0 || index>=WAV_COUNT || sfx_voice[index]==-1)
8333 4903 return;
8334
8335 voice_set_playmode(sfx_voice[index],loop?PLAYMODE_LOOP:PLAYMODE_PLAY);
8336 voice_set_pan(sfx_voice[index],pan);
8337 4903 }
8338
8339 // pauses a voice
8340 3223 void pause_sfx(int32_t index)
8341 {
8342
3/6
✓ Branch 0 taken 3223 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3223 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 3223 times.
3223 if(index>0 && index<WAV_COUNT && sfx_voice[index]!=-1)
8343 voice_stop(sfx_voice[index]);
8344 3223 }
8345
8346 // resumes a voice
8347 1360 void resume_sfx(int32_t index)
8348 {
8349
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1360 times.
1360 if (is_headless())
8350 1360 return;
8351
8352 if(index>0 && index<WAV_COUNT && sfx_voice[index]!=-1)
8353 voice_start(sfx_voice[index]);
8354 1360 }
8355
8356 // pauses all active voices
8357 1072 void pause_all_sfx()
8358 {
8359
2/2
✓ Branch 0 taken 274432 times.
✓ Branch 1 taken 1072 times.
275504 for(int32_t i=0; i<WAV_COUNT; i++)
8360
2/2
✓ Branch 0 taken 274430 times.
✓ Branch 1 taken 2 times.
274434 if(sfx_voice[i]!=-1)
8361 2 voice_stop(sfx_voice[i]);
8362 1072 }
8363
8364 // resumes all paused voices
8365 1017 void resume_all_sfx()
8366 {
8367
2/2
✓ Branch 0 taken 260352 times.
✓ Branch 1 taken 1017 times.
261369 for(int32_t i=0; i<WAV_COUNT; i++)
8368
1/2
✓ Branch 0 taken 260352 times.
✗ Branch 1 not taken.
260352 if(sfx_voice[i]!=-1)
8369 voice_start(sfx_voice[i]);
8370 1017 }
8371
8372 // stops an sfx and deallocates the voice
8373 14464641 void stop_sfx(int32_t index)
8374 {
8375
3/4
✓ Branch 0 taken 14218318 times.
✓ Branch 1 taken 246323 times.
✓ Branch 2 taken 14218318 times.
✗ Branch 3 not taken.
14464641 if(index<=0 || index>=WAV_COUNT)
8376 246323 return;
8377
8378
2/2
✓ Branch 0 taken 33 times.
✓ Branch 1 taken 14218285 times.
14218318 if(sfx_voice[index]!=-1)
8379 {
8380 33 deallocate_voice(sfx_voice[index]);
8381 33 sfx_voice[index]=-1;
8382 33 }
8383 14464641 }
8384
8385 // Stops SFX played by Hero's item of the given family
8386 129758 void stop_item_sfx(int32_t family)
8387 {
8388 129758 int32_t id=current_item_id(family);
8389
8390
2/2
✓ Branch 0 taken 128658 times.
✓ Branch 1 taken 1100 times.
129758 if(id<0)
8391 128658 return;
8392
8393 1100 stop_sfx(itemsbuf[id].usesound);
8394 129758 }
8395
8396 9165 void kill_sfx()
8397 {
8398
2/2
✓ Branch 0 taken 2346240 times.
✓ Branch 1 taken 9165 times.
2355405 for(int32_t i=0; i<WAV_COUNT; i++)
8399
2/2
✓ Branch 0 taken 2346182 times.
✓ Branch 1 taken 58 times.
2346298 if(sfx_voice[i]!=-1)
8400 {
8401 58 deallocate_voice(sfx_voice[i]);
8402 58 sfx_voice[i]=-1;
8403 58 }
8404 9165 }
8405
8406 1172880 int32_t pan(int32_t x)
8407 {
8408
1/4
✓ Branch 0 taken 1172880 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
1172880 switch(pan_style)
8409 {
8410 case 0:
8411 return 128;
8412
8413 case 1:
8414 1172880 return vbound((x>>1)+68,0,255);
8415
8416 case 2:
8417 return vbound(((x*3)>>2)+36,0,255);
8418 }
8419
8420 return vbound(x,0,255);
8421 1172880 }
8422
8423 49898820 bool joybtn(int32_t b)
8424 {
8425
1/2
✓ Branch 0 taken 49898820 times.
✗ Branch 1 not taken.
49898820 if(b == 0)
8426 return false;
8427
1/2
✓ Branch 0 taken 49898820 times.
✗ Branch 1 not taken.
49898820 if (b-1 >= joy[joystick_index].num_buttons)
8428 49898820 return false;
8429
8430 return joy[joystick_index].button[b-1].b !=0;
8431 49898820 }
8432
8433 bool joystick(int32_t s)
8434 {
8435 if(s < 0)
8436 return false;
8437 if (s >= joy[joystick_index].num_sticks)
8438 return false;
8439
8440 for (int i = 0; i < joy[joystick_index].stick[s].num_axis; i++)
8441 {
8442 if (joy[joystick_index].stick[s].axis[i].d1 || joy[joystick_index].stick[s].axis[i].d2)
8443 return true;
8444 }
8445 return false;
8446 }
8447
8448 const char* joybtn_name(int32_t b)
8449 {
8450 if (b <= 0 || b > joy[joystick_index].num_buttons)
8451 return "";
8452
8453 return joy[joystick_index].button[b-1].name;
8454 }
8455
8456 const char* joystick_name(int32_t s)
8457 {
8458 if (s < 0 || s >= joy[joystick_index].num_sticks)
8459 return "";
8460
8461 return joy[joystick_index].stick[s].name;
8462 }
8463
8464 int32_t button_pressed()
8465 {
8466 if (joystick_index >= MAX_JOYSTICKS)
8467 return 0;
8468
8469 for(int32_t i=1; i<=joy[joystick_index].num_buttons; i++)
8470 {
8471 if(joybtn(i))
8472 return i;
8473 }
8474
8475 return 0;
8476 }
8477
8478 int32_t next_press_key();
8479
8480 int32_t next_joy_input(bool buttons)
8481 {
8482 clear_keybuf();
8483
8484 //first, we need to wait until they're pressing no buttons
8485 for(;;)
8486 {
8487 if(keypressed())
8488 {
8489 switch(readkey()>>8)
8490 {
8491 case KEY_ESC:
8492 return -1;
8493
8494 case KEY_SPACE:
8495 return 0;
8496 }
8497 }
8498
8499 poll_joystick();
8500 bool done = true;
8501
8502 if (buttons)
8503 {
8504 for(int32_t i=1; i<=joy[joystick_index].num_buttons; i++)
8505 {
8506 if(joybtn(i)) done = false;
8507 }
8508 }
8509 else
8510 {
8511 if (!gamepad_dlg_cur_joystick || !al_get_joystick_active(gamepad_dlg_cur_joystick))
8512 {
8513 InfoDialog("ZC", "Invalid gamepad. Did it disconnect?").show();
8514 return -2;
8515 }
8516 for(int32_t i=0; i<joy[joystick_index].num_sticks; i++)
8517 {
8518 if(joystick(i)) done = false;
8519 }
8520 }
8521
8522 if(done) break;
8523 rest(1);
8524 }
8525
8526 //now, we need to wait for them to press any button
8527 for(;;)
8528 {
8529 if(keypressed())
8530 {
8531 switch(readkey()>>8)
8532 {
8533 case KEY_ESC:
8534 return -1;
8535
8536 case KEY_SPACE:
8537 return 0;
8538 }
8539 }
8540
8541 poll_joystick();
8542
8543 if (buttons)
8544 {
8545 if (!gamepad_dlg_cur_joystick || !al_get_joystick_active(gamepad_dlg_cur_joystick))
8546 {
8547 InfoDialog("ZC", "Invalid gamepad. Did it disconnect?").show();
8548 return -2;
8549 }
8550 for(int32_t i=1; i<=joy[joystick_index].num_buttons; i++)
8551 {
8552 if(joybtn(i))
8553 return i;
8554 }
8555 }
8556 else
8557 {
8558 for(int32_t i=0; i<joy[joystick_index].num_sticks; i++)
8559 {
8560 if(joystick(i))
8561 return i;
8562 }
8563 }
8564 rest(1);
8565 }
8566 }
8567
8568 7240529 static bool rButton(bool &btn, bool &flag, bool rawbtn)
8569 {
8570
2/2
✓ Branch 0 taken 7214975 times.
✓ Branch 1 taken 25554 times.
7240529 bool ret = btn && !flag;
8571 7240529 flag = rawbtn;
8572
8573 7240529 return ret;
8574 }
8575 373615728 static bool rButton(bool &btn, bool &flag)
8576 {
8577
2/2
✓ Branch 0 taken 359853440 times.
✓ Branch 1 taken 13762288 times.
373615728 bool ret = btn && !flag;
8578 373615728 flag = btn;
8579
8580 373615728 return ret;
8581 }
8582 4574878 static bool rButtonPeek(bool btn, bool flag)
8583 {
8584
2/2
✓ Branch 0 taken 4234696 times.
✓ Branch 1 taken 340182 times.
4574878 if(!btn)
8585 {
8586 4234696 return false;
8587 }
8588
2/2
✓ Branch 0 taken 33303 times.
✓ Branch 1 taken 306879 times.
340182 else if(!flag)
8589 {
8590 33303 return true;
8591 }
8592
8593 306879 return false;
8594 4574878 }
8595
8596 // Updated only by keyboard/gamepad.
8597 // If in replay mode, this is set directly by the replay system.
8598 // This should never be read from directly - use control_state instead.
8599 bool raw_control_state[ZC_CONTROL_STATES];
8600
8601 // Every call to load_control_state (pretty much every frame) resets this to be equal to raw_control_state.
8602 // This state can drift from raw_control_state if button states are "eaten" or overriden by a script. But that only
8603 // lasts until the next call to load_control_state.
8604 bool control_state[ZC_CONTROL_STATES];
8605 bool disable_control[ZC_CONTROL_STATES];
8606 bool drunk_toggle_state[11];
8607 bool disabledKeys[127];
8608 bool KeyInput[127];
8609 bool KeyPress[127];
8610
8611 bool key_current_frame[127];
8612 bool key_previous_frame[127];
8613
8614 static bool key_system[127];
8615 static bool key_system_previous[127];
8616 static bool key_system_press[127];
8617
8618 bool button_press[ZC_CONTROL_STATES];
8619 bool button_hold[ZC_CONTROL_STATES];
8620
8621 #define STICK_1_X joy[joystick_index].stick[js_stick_1_x_stick].axis[js_stick_1_x_axis]
8622 #define STICK_1_Y joy[joystick_index].stick[js_stick_1_y_stick].axis[js_stick_1_y_axis]
8623 #define STICK_2_X joy[joystick_index].stick[js_stick_2_x_stick].axis[js_stick_2_x_axis]
8624 #define STICK_2_Y joy[joystick_index].stick[js_stick_2_y_stick].axis[js_stick_2_y_axis]
8625 #define STICK_PRECISION 56 //define your own sensitivity
8626
8627 15505307 void load_control_state()
8628 {
8629 15505307 load_control_called_this_frame = true;
8630
8631
2/2
✓ Branch 0 taken 12375675 times.
✓ Branch 1 taken 3129632 times.
15505307 if (replay_version_check(8, 11))
8632 {
8633
2/2
✓ Branch 0 taken 56333376 times.
✓ Branch 1 taken 3129632 times.
59463008 for (int i = 0; i < ZC_CONTROL_STATES; i++)
8634 56333376 down_control_states[i] = raw_control_state[i];
8635 3129632 }
8636
8637
2/2
✓ Branch 0 taken 15505286 times.
✓ Branch 1 taken 21 times.
15505307 if (!replay_is_replaying())
8638 {
8639
3/6
✗ Branch 0 not taken.
✓ Branch 1 taken 21 times.
✓ Branch 2 taken 21 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 21 times.
✗ Branch 5 not taken.
21 raw_control_state[0]=zc_getrawkey(DUkey, true)||(analog_movement ? STICK_1_Y.d1 || STICK_1_Y.pos - js_stick_1_y_offset < -STICK_PRECISION : joybtn(DUbtn));
8640
3/6
✗ Branch 0 not taken.
✓ Branch 1 taken 21 times.
✓ Branch 2 taken 21 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 21 times.
✗ Branch 5 not taken.
21 raw_control_state[1]=zc_getrawkey(DDkey, true)||(analog_movement ? STICK_1_Y.d2 || STICK_1_Y.pos - js_stick_1_y_offset > STICK_PRECISION : joybtn(DDbtn));
8641
3/6
✗ Branch 0 not taken.
✓ Branch 1 taken 21 times.
✓ Branch 2 taken 21 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 21 times.
✗ Branch 5 not taken.
21 raw_control_state[2]=zc_getrawkey(DLkey, true)||(analog_movement ? STICK_1_X.d1 || STICK_1_X.pos - js_stick_1_x_offset < -STICK_PRECISION : joybtn(DLbtn));
8642
3/6
✗ Branch 0 not taken.
✓ Branch 1 taken 21 times.
✓ Branch 2 taken 21 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 21 times.
✗ Branch 5 not taken.
21 raw_control_state[3]=zc_getrawkey(DRkey, true)||(analog_movement ? STICK_1_X.d2 || STICK_1_X.pos - js_stick_1_x_offset > STICK_PRECISION : joybtn(DRbtn));
8643
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 21 times.
21 raw_control_state[4]=zc_getrawkey(Akey, true)||joybtn(Abtn);
8644
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 21 times.
21 raw_control_state[5]=zc_getrawkey(Bkey, true)||joybtn(Bbtn);
8645
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 21 times.
21 raw_control_state[6]=zc_getrawkey(Skey, true)||joybtn(Sbtn);
8646
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 21 times.
21 raw_control_state[7]=zc_getrawkey(Lkey, true)||joybtn(Lbtn);
8647
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 21 times.
21 raw_control_state[8]=zc_getrawkey(Rkey, true)||joybtn(Rbtn);
8648
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 21 times.
21 raw_control_state[9]=zc_getrawkey(Pkey, true)||joybtn(Pbtn);
8649
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 21 times.
21 raw_control_state[10]=zc_getrawkey(Exkey1, true)||joybtn(Exbtn1);
8650
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 21 times.
21 raw_control_state[11]=zc_getrawkey(Exkey2, true)||joybtn(Exbtn2);
8651
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 21 times.
21 raw_control_state[12]=zc_getrawkey(Exkey3, true)||joybtn(Exbtn3);
8652
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 21 times.
21 raw_control_state[13]=zc_getrawkey(Exkey4, true)||joybtn(Exbtn4);
8653
8654
1/2
✓ Branch 0 taken 21 times.
✗ Branch 1 not taken.
21 if(num_joysticks != 0)
8655 {
8656 raw_control_state[14] = STICK_2_Y.pos - js_stick_2_y_offset < -STICK_PRECISION;
8657 raw_control_state[15] = STICK_2_Y.pos - js_stick_2_y_offset > STICK_PRECISION;
8658 raw_control_state[16] = STICK_2_X.pos - js_stick_2_x_offset < -STICK_PRECISION;
8659 raw_control_state[17] = STICK_2_X.pos - js_stick_2_x_offset > STICK_PRECISION;
8660 }
8661 else
8662 {
8663 21 raw_control_state[14] = false;
8664 21 raw_control_state[15] = false;
8665 21 raw_control_state[16] = false;
8666 21 raw_control_state[17] = false;
8667 }
8668 21 }
8669
2/2
✓ Branch 0 taken 5 times.
✓ Branch 1 taken 15505302 times.
15505307 if (replay_is_active())
8670 {
8671
2/2
✓ Branch 0 taken 1211700 times.
✓ Branch 1 taken 14293602 times.
15505302 if (replay_get_version() < 3)
8672 1211700 replay_poll();
8673
4/4
✓ Branch 0 taken 14293581 times.
✓ Branch 1 taken 21 times.
✓ Branch 2 taken 12532206 times.
✓ Branch 3 taken 1761375 times.
14293602 else if (replay_is_replaying() && replay_get_version() < 6)
8674 1761375 replay_peek_input();
8675
4/4
✓ Branch 0 taken 12532206 times.
✓ Branch 1 taken 21 times.
✓ Branch 2 taken 9402574 times.
✓ Branch 3 taken 3129632 times.
12532227 else if (replay_is_replaying() && replay_version_check(8, 11))
8676 3129632 replay_peek_input();
8677
2/2
✓ Branch 0 taken 14238790 times.
✓ Branch 1 taken 1266512 times.
15505302 if (replay_get_version() == 8)
8678 1266512 update_keys();
8679 15505302 }
8680
8681 // Some test replay files were made before a serious input bug was fixed, so instead
8682 // of re-doing them or tossing them out, just check for that zplay version.
8683
3/4
✓ Branch 0 taken 15505297 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 121900 times.
✓ Branch 3 taken 15383397 times.
15505307 bool botched_input = replay_is_active() && replay_get_version() != 1 && replay_get_version() < 8;
8684
2/2
✓ Branch 0 taken 279095346 times.
✓ Branch 1 taken 15505297 times.
294600643 for (int i = 0; i < ZC_CONTROL_STATES; i++)
8685 {
8686 279095346 control_state[i] = raw_control_state[i];
8687
4/4
✓ Branch 0 taken 53024022 times.
✓ Branch 1 taken 226071324 times.
✓ Branch 2 taken 2611994 times.
✓ Branch 3 taken 50412028 times.
279095346 if (botched_input && !control_state[i])
8688 50412028 down_control_states[i] = false;
8689 279095346 }
8690 15505297 bool did_bad_cutscene_btn = false;
8691
2/2
✓ Branch 0 taken 15505297 times.
✓ Branch 1 taken 279095346 times.
294600643 for(int q = 0; q < 18; ++q)
8692
4/4
✓ Branch 0 taken 13193425 times.
✓ Branch 1 taken 265901921 times.
✓ Branch 2 taken 13191842 times.
✓ Branch 3 taken 1583 times.
279096929 if(control_state[q] && !active_cutscene.can_button(q))
8693 {
8694 1583 control_state[q] = false;
8695 1583 did_bad_cutscene_btn = true;
8696 1583 }
8697
2/2
✓ Branch 0 taken 15504152 times.
✓ Branch 1 taken 1145 times.
15505297 if(did_bad_cutscene_btn)
8698 1145 active_cutscene.error();
8699
8700 15505297 button_press[0]=rButton(control_state[0],button_hold[0]);
8701 15505297 button_press[1]=rButton(control_state[1],button_hold[1]);
8702 15505297 button_press[2]=rButton(control_state[2],button_hold[2]);
8703 15505297 button_press[3]=rButton(control_state[3],button_hold[3]);
8704 15505297 button_press[4]=rButton(control_state[4],button_hold[4]);
8705 15505297 button_press[5]=rButton(control_state[5],button_hold[5]);
8706 15505297 button_press[6]=rButton(control_state[6],button_hold[6]);
8707 15505297 button_press[7]=rButton(control_state[7],button_hold[7]);
8708 15505297 button_press[8]=rButton(control_state[8],button_hold[8]);
8709 15505297 button_press[9]=rButton(control_state[9],button_hold[9]);
8710 15505297 button_press[10]=rButton(control_state[10],button_hold[10]);
8711 15505297 button_press[11]=rButton(control_state[11],button_hold[11]);
8712 15505297 button_press[12]=rButton(control_state[12],button_hold[12]);
8713 15505297 button_press[13]=rButton(control_state[13],button_hold[13]);
8714 15505297 button_press[14]=rButton(control_state[14],button_hold[14]);
8715 15505297 button_press[15]=rButton(control_state[15],button_hold[15]);
8716 15505297 button_press[16]=rButton(control_state[16],button_hold[16]);
8717 15505297 button_press[17]=rButton(control_state[17],button_hold[17]);
8718 15505297 }
8719
8720 // Returns true if any game key is pressed. This is needed because keypressed()
8721 // doesn't detect modifier keys and control_state[] can be modified by scripts.
8722 77849705 bool zc_key_pressed()
8723 //may also need to use zc_getrawkey
8724 {
8725
7/10
✓ Branch 0 taken 62873451 times.
✓ Branch 1 taken 14976254 times.
✓ Branch 2 taken 14976254 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 14976254 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 12263296 times.
✓ Branch 7 taken 12263296 times.
✗ Branch 8 not taken.
✓ Branch 9 taken 4911060 times.
82760765 if((zc_getrawkey(DUkey, true)||(analog_movement ? STICK_1_Y.d1 || STICK_1_Y.pos - js_stick_1_y_offset< -STICK_PRECISION : joybtn(DUbtn))) ||
8726
4/6
✓ Branch 0 taken 12263296 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12263296 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 9338646 times.
✓ Branch 5 taken 9338646 times.
12263296 (zc_getrawkey(DDkey, true)||(analog_movement ? STICK_1_Y.d2 || STICK_1_Y.pos - js_stick_1_y_offset > STICK_PRECISION : joybtn(DDbtn))) ||
8727
4/6
✓ Branch 0 taken 9338646 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 9338646 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 6191216 times.
✓ Branch 5 taken 6191216 times.
9338646 (zc_getrawkey(DLkey, true)||(analog_movement ? STICK_1_X.d1 || STICK_1_X.pos - js_stick_1_x_offset < -STICK_PRECISION : joybtn(DLbtn))) ||
8728
4/6
✓ Branch 0 taken 6191216 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 6191216 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 5314612 times.
✓ Branch 5 taken 5314612 times.
6191216 (zc_getrawkey(DRkey, true)||(analog_movement ? STICK_1_X.d2 || STICK_1_X.pos - js_stick_1_x_offset > STICK_PRECISION : joybtn(DRbtn))) ||
8729
1/2
✓ Branch 0 taken 5314612 times.
✗ Branch 1 not taken.
5314612 (zc_getrawkey(Akey, true)||joybtn(Abtn)) ||
8730
3/4
✓ Branch 0 taken 5128945 times.
✓ Branch 1 taken 185667 times.
✓ Branch 2 taken 5128945 times.
✗ Branch 3 not taken.
5314612 (zc_getrawkey(Bkey, true)||joybtn(Bbtn)) ||
8731
3/4
✓ Branch 0 taken 4982840 times.
✓ Branch 1 taken 146105 times.
✓ Branch 2 taken 4982840 times.
✗ Branch 3 not taken.
5128945 (zc_getrawkey(Skey, true)||joybtn(Sbtn)) ||
8732
3/4
✓ Branch 0 taken 4961970 times.
✓ Branch 1 taken 20870 times.
✓ Branch 2 taken 4961970 times.
✗ Branch 3 not taken.
4982840 (zc_getrawkey(Lkey, true)||joybtn(Lbtn)) ||
8733
3/4
✓ Branch 0 taken 4935611 times.
✓ Branch 1 taken 26359 times.
✓ Branch 2 taken 4935611 times.
✗ Branch 3 not taken.
4961970 (zc_getrawkey(Rkey, true)||joybtn(Rbtn)) ||
8734
3/4
✓ Branch 0 taken 4928326 times.
✓ Branch 1 taken 7285 times.
✓ Branch 2 taken 4928326 times.
✗ Branch 3 not taken.
4935611 (zc_getrawkey(Pkey, true)||joybtn(Pbtn)) ||
8735
3/4
✓ Branch 0 taken 4912973 times.
✓ Branch 1 taken 15353 times.
✓ Branch 2 taken 4912973 times.
✗ Branch 3 not taken.
4928326 (zc_getrawkey(Exkey1, true)||joybtn(Exbtn1)) ||
8736
3/4
✓ Branch 0 taken 4911154 times.
✓ Branch 1 taken 1819 times.
✓ Branch 2 taken 4911154 times.
✗ Branch 3 not taken.
4912973 (zc_getrawkey(Exkey2, true)||joybtn(Exbtn2)) ||
8737
3/4
✓ Branch 0 taken 4911119 times.
✓ Branch 1 taken 35 times.
✓ Branch 2 taken 4911119 times.
✗ Branch 3 not taken.
4911154 (zc_getrawkey(Exkey3, true)||joybtn(Exbtn3)) ||
8738
2/2
✓ Branch 0 taken 4911060 times.
✓ Branch 1 taken 59 times.
4911119 (zc_getrawkey(Exkey4, true)||joybtn(Exbtn4))) // Skipping joystick axes
8739 139154185 return true;
8740
8741 4911060 return false;
8742 18318343 }
8743
8744 294634601 bool getInput(int32_t btn, bool press, bool drunk, bool ignoreDisable, bool eatEntirely, bool peek)
8745 {
8746 294634601 bool ret = false, drunkstate = false, rawret = false;;
8747 294634601 bool* flag = &down_control_states[btn];
8748
2/7
✓ Branch 0 taken 276297455 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✓ Branch 6 taken 18337146 times.
294634601 switch(btn)
8749 {
8750 case btnF12:
8751 ret = zc_getkey(KEY_F12, ignoreDisable);
8752 rawret = zc_getrawkey(KEY_F12, ignoreDisable);
8753 eatEntirely = false;
8754 break;
8755 case btnF11:
8756 ret = zc_getkey(KEY_F11, ignoreDisable);
8757 rawret = zc_getrawkey(KEY_F11, ignoreDisable);
8758 eatEntirely = false;
8759 break;
8760 case btnF5:
8761 ret = zc_getkey(KEY_F5, ignoreDisable);
8762 rawret = zc_getrawkey(KEY_F5, ignoreDisable);
8763 eatEntirely = false;
8764 break;
8765 case btnQ:
8766 ret = zc_getkey(KEY_Q, ignoreDisable);
8767 rawret = zc_getrawkey(KEY_Q, ignoreDisable);
8768 eatEntirely = false;
8769 break;
8770 case btnI:
8771 ret = zc_getkey(KEY_I, ignoreDisable);
8772 rawret = zc_getrawkey(KEY_I, ignoreDisable);
8773 eatEntirely = false;
8774 break;
8775 case btnM:
8776
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 18337146 times.
18337146 if(FFCore.kb_typing_mode) return false;
8777 18337146 rawret = ret = zc_getrawkey(KEY_ESC, ignoreDisable);
8778 18337146 eatEntirely = false;
8779 18337146 break;
8780 default: //control_state[] index
8781
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 276297455 times.
276297455 if(FFCore.kb_typing_mode) return false;
8782
6/6
✓ Branch 0 taken 274919447 times.
✓ Branch 1 taken 1378008 times.
✓ Branch 2 taken 16536341 times.
✓ Branch 3 taken 258383106 times.
✓ Branch 4 taken 16536188 times.
✓ Branch 5 taken 153 times.
276297455 if(!ignoreDisable && get_qr(qr_FIXDRUNKINPUTS) && disable_control[btn]) drunk = false;
8783
2/2
✓ Branch 0 taken 15728053 times.
✓ Branch 1 taken 260569249 times.
276297302 else if(btn<11) drunkstate = drunk_toggle_state[btn];
8784
4/4
✓ Branch 0 taken 245520317 times.
✓ Branch 1 taken 30777138 times.
✓ Branch 2 taken 7155 times.
✓ Branch 3 taken 30769983 times.
307074593 ret = control_state[btn] && (ignoreDisable || !disable_control[btn]);
8785 276297455 rawret = raw_control_state[btn];
8786 276297455 }
8787
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 294634601 times.
294634601 assert(flag);
8788
2/2
✓ Branch 0 taken 188298812 times.
✓ Branch 1 taken 106335789 times.
294634601 if(press)
8789 {
8790
2/2
✓ Branch 0 taken 4574878 times.
✓ Branch 1 taken 101760911 times.
106335789 if(peek)
8791 4574878 ret = rButtonPeek(ret, *flag);
8792
2/2
✓ Branch 0 taken 94520382 times.
✓ Branch 1 taken 7240529 times.
101760911 else if(get_qr(qr_BROKEN_INPUT_DOWN_STATE)) ret = rButton(ret, *flag);
8793 7240529 else ret = rButton(ret, *flag, rawret);
8794 106335789 }
8795
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 294634601 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
294634601 if(eatEntirely && ret) control_state[btn] = false;
8796
4/4
✓ Branch 0 taken 220128723 times.
✓ Branch 1 taken 74505878 times.
✓ Branch 2 taken 220128642 times.
✓ Branch 3 taken 81 times.
294634601 if(drunk && drunkstate) ret = !ret;
8797 294634601 return ret;
8798 294634601 }
8799
8800 14795919 byte getIntBtnInput(byte intbtn, bool press, bool drunk, bool ignoreDisable, bool eatEntirely, bool peek)
8801 {
8802 14795919 byte ret = 0;
8803
2/2
✓ Branch 0 taken 10444473 times.
✓ Branch 1 taken 4351446 times.
14795919 if(intbtn & INT_BTN_A) ret |= getInput(btnA, press, drunk, ignoreDisable, eatEntirely, peek) ? INT_BTN_A : 0;
8804
2/2
✓ Branch 0 taken 14588690 times.
✓ Branch 1 taken 207229 times.
14795919 if(intbtn & INT_BTN_B) ret |= getInput(btnB, press, drunk, ignoreDisable, eatEntirely, peek) ? INT_BTN_B : 0;
8805
2/2
✓ Branch 0 taken 14589137 times.
✓ Branch 1 taken 206782 times.
14795919 if(intbtn & INT_BTN_L) ret |= getInput(btnL, press, drunk, ignoreDisable, eatEntirely, peek) ? INT_BTN_L : 0;
8806
2/2
✓ Branch 0 taken 14589137 times.
✓ Branch 1 taken 206782 times.
14795919 if(intbtn & INT_BTN_R) ret |= getInput(btnR, press, drunk, ignoreDisable, eatEntirely, peek) ? INT_BTN_R : 0;
8807
2/2
✓ Branch 0 taken 14589137 times.
✓ Branch 1 taken 206782 times.
14795919 if(intbtn & INT_BTN_EX1) ret |= getInput(btnEx1, press, drunk, ignoreDisable, eatEntirely, peek) ? INT_BTN_EX1 : 0;
8808
2/2
✓ Branch 0 taken 14589137 times.
✓ Branch 1 taken 206782 times.
14795919 if(intbtn & INT_BTN_EX2) ret |= getInput(btnEx2, press, drunk, ignoreDisable, eatEntirely, peek) ? INT_BTN_EX2 : 0;
8809
2/2
✓ Branch 0 taken 14589137 times.
✓ Branch 1 taken 206782 times.
14795919 if(intbtn & INT_BTN_EX3) ret |= getInput(btnEx3, press, drunk, ignoreDisable, eatEntirely, peek) ? INT_BTN_EX3 : 0;
8810
2/2
✓ Branch 0 taken 14589022 times.
✓ Branch 1 taken 206897 times.
14795919 if(intbtn & INT_BTN_EX4) ret |= getInput(btnEx4, press, drunk, ignoreDisable, eatEntirely, peek) ? INT_BTN_EX4 : 0;
8811 14795919 return ret; //No early return, to make sure all button presses are eaten that should be! -Em
8812 }
8813
8814 7010 byte checkIntBtnVal(byte intbtn, byte vals)
8815 {
8816 7010 return intbtn&vals;
8817 }
8818
8819 3710445 bool Up()
8820 {
8821 3710445 return getInput(btnUp);
8822 }
8823 726817 bool Down()
8824 {
8825 726817 return getInput(btnDown);
8826 }
8827 979837 bool Left()
8828 {
8829 979837 return getInput(btnLeft);
8830 }
8831 1040595 bool Right()
8832 {
8833 1040595 return getInput(btnRight);
8834 }
8835 537139 bool cAbtn()
8836 {
8837 537139 return getInput(btnA);
8838 }
8839 3312971 bool cBbtn()
8840 {
8841 3312971 return getInput(btnB);
8842 }
8843 bool cSbtn()
8844 {
8845 return getInput(btnS);
8846 }
8847 208608 bool cLbtn()
8848 {
8849 208608 return getInput(btnL);
8850 }
8851 208608 bool cRbtn()
8852 {
8853 208608 return getInput(btnR);
8854 }
8855 bool cPbtn()
8856 {
8857 return getInput(btnP);
8858 }
8859 bool cEx1btn()
8860 {
8861 return getInput(btnEx1);
8862 }
8863 bool cEx2btn()
8864 {
8865 return getInput(btnEx2);
8866 }
8867 bool cEx3btn()
8868 {
8869 return getInput(btnEx3);
8870 }
8871 bool cEx4btn()
8872 {
8873 return getInput(btnEx4);
8874 }
8875 bool AxisUp()
8876 {
8877 return getInput(btnAxisUp);
8878 }
8879 bool AxisDown()
8880 {
8881 return getInput(btnAxisDown);
8882 }
8883 bool AxisLeft()
8884 {
8885 return getInput(btnAxisLeft);
8886 }
8887 bool AxisRight()
8888 {
8889 return getInput(btnAxisRight);
8890 }
8891
8892 bool cMbtn()
8893 {
8894 return getInput(btnM);
8895 }
8896 bool cF12()
8897 {
8898 return getInput(btnF12);
8899 }
8900 bool cF11()
8901 {
8902 return getInput(btnF11);
8903 }
8904 bool cF5()
8905 {
8906 return getInput(btnF5);
8907 }
8908 bool cQ()
8909 {
8910 return getInput(btnQ);
8911 }
8912 bool cI()
8913 {
8914 return getInput(btnI);
8915 }
8916
8917 208304 bool rUp()
8918 {
8919 208304 return getInput(btnUp, true);
8920 }
8921 208096 bool rDown()
8922 {
8923 208096 return getInput(btnDown, true);
8924 }
8925 207900 bool rLeft()
8926 {
8927 207900 return getInput(btnLeft, true);
8928 }
8929 207171 bool rRight()
8930 {
8931 207171 return getInput(btnRight, true);
8932 }
8933 6589 bool rAbtn()
8934 {
8935 6589 return getInput(btnA, true);
8936 }
8937 4638 bool rBbtn()
8938 {
8939 4638 return getInput(btnB, true);
8940 }
8941 14366917 bool rSbtn()
8942 {
8943 14366917 return getInput(btnS, true);
8944 }
8945 18318343 bool rMbtn()
8946 {
8947 18318343 return getInput(btnM, true);
8948 }
8949 185250 bool rLbtn()
8950 {
8951 185250 return getInput(btnL, true);
8952 }
8953 185245 bool rRbtn()
8954 {
8955 185245 return getInput(btnR, true);
8956 }
8957 14367651 bool rPbtn()
8958 {
8959 14367651 return getInput(btnP, true);
8960 }
8961 bool rEx1btn()
8962 {
8963 return getInput(btnEx1, true);
8964 }
8965 bool rEx2btn()
8966 {
8967 return getInput(btnEx2, true);
8968 }
8969 195896 bool rEx3btn()
8970 {
8971 195896 return getInput(btnEx3, true);
8972 }
8973 195896 bool rEx4btn()
8974 {
8975 195896 return getInput(btnEx4, true);
8976 }
8977 bool rAxisUp()
8978 {
8979 return getInput(btnAxisUp, true);
8980 }
8981 bool rAxisDown()
8982 {
8983 return getInput(btnAxisDown, true);
8984 }
8985 bool rAxisLeft()
8986 {
8987 return getInput(btnAxisLeft, true);
8988 }
8989 bool rAxisRight()
8990 {
8991 return getInput(btnAxisRight, true);
8992 }
8993
8994 bool rF11()
8995 {
8996 return getInput(btnF11, true);
8997 }
8998 bool rQ()
8999 {
9000 return getInput(btnQ, true);
9001 }
9002 bool rI()
9003 {
9004 return getInput(btnI, true);
9005 }
9006
9007 36581418 bool DrunkUp()
9008 {
9009 36581418 return getInput(btnUp, false, true);
9010 }
9011 33382974 bool DrunkDown()
9012 {
9013 33382974 return getInput(btnDown, false, true);
9014 }
9015 19578341 bool DrunkLeft()
9016 {
9017 19578341 return getInput(btnLeft, false, true);
9018 }
9019 16658670 bool DrunkRight()
9020 {
9021 16658670 return getInput(btnRight, false, true);
9022 }
9023 15772123 bool DrunkcAbtn()
9024 {
9025 15772123 return getInput(btnA, false, true);
9026 }
9027 15208529 bool DrunkcBbtn()
9028 {
9029 15208529 return getInput(btnB, false, true);
9030 }
9031 14158857 bool DrunkcEx1btn()
9032 {
9033 14158857 return getInput(btnEx1, false, true);
9034 }
9035 14157489 bool DrunkcEx2btn()
9036 {
9037 14157489 return getInput(btnEx2, false, true);
9038 }
9039 bool DrunkcSbtn()
9040 {
9041 return getInput(btnS, false, true);
9042 }
9043 bool DrunkcMbtn()
9044 {
9045 return getInput(btnM, false, true);
9046 }
9047 bool DrunkcLbtn()
9048 {
9049 return getInput(btnL, false, true);
9050 }
9051 bool DrunkcRbtn()
9052 {
9053 return getInput(btnR, false, true);
9054 }
9055 bool DrunkcPbtn()
9056 {
9057 return getInput(btnP, false, true);
9058 }
9059
9060 bool DrunkrUp()
9061 {
9062 return getInput(btnUp, true, true);
9063 }
9064 bool DrunkrDown()
9065 {
9066 return getInput(btnDown, true, true);
9067 }
9068 bool DrunkrLeft()
9069 {
9070 return getInput(btnLeft, true, true);
9071 }
9072 bool DrunkrRight()
9073 {
9074 return getInput(btnRight, true, true);
9075 }
9076 11830634 bool DrunkrAbtn()
9077 {
9078 11830634 return getInput(btnA, true, true);
9079 }
9080 11859166 bool DrunkrBbtn()
9081 {
9082 11859166 return getInput(btnB, true, true);
9083 }
9084 502081 bool DrunkrEx1btn()
9085 {
9086 502081 return getInput(btnEx1, true, true);
9087 }
9088 501902 bool DrunkrEx2btn()
9089 {
9090 501902 return getInput(btnEx2, true, true);
9091 }
9092 bool DrunkrEx3btn()
9093 {
9094 return getInput(btnEx3, true, true);
9095 }
9096 bool DrunkrEx4btn()
9097 {
9098 return getInput(btnEx4, true, true);
9099 }
9100 bool DrunkrSbtn()
9101 {
9102 return getInput(btnS, true, true);
9103 }
9104 bool DrunkrMbtn()
9105 {
9106 return getInput(btnM, true, true);
9107 }
9108 12896561 bool DrunkrLbtn()
9109 {
9110 12896561 return getInput(btnL, true, true);
9111 }
9112 12891256 bool DrunkrRbtn()
9113 {
9114 12891256 return getInput(btnR, true, true);
9115 }
9116 bool DrunkrPbtn()
9117 {
9118 return getInput(btnP, true, true);
9119 }
9120
9121 18803 void eat_buttons()
9122 {
9123 18803 getInput(btnA, true, false, true);
9124 18803 getInput(btnB, true, false, true);
9125 18803 getInput(btnS, true, false, true);
9126 18803 getInput(btnM, true, false, true);
9127 18803 getInput(btnL, true, false, true);
9128 18803 getInput(btnR, true, false, true);
9129 18803 getInput(btnP, true, false, true);
9130 18803 getInput(btnEx1, true, false, true);
9131 18803 getInput(btnEx2, true, false, true);
9132 18803 getInput(btnEx3, true, false, true);
9133 18803 getInput(btnEx4, true, false, true);
9134 18803 }
9135
9136 // Is true for the _first frame_ of a key press.
9137 // But! it is possible that a script manually sets the value of KeyPress,
9138 // in which case it will be restored to the "true" value based on `key_current_frame`
9139 // and `key_previous_frame` on the next frame.
9140 55 bool zc_readkey(int32_t k, bool ignoreDisable)
9141 {
9142
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 55 times.
55 if(ignoreDisable) return KeyPress[k];
9143
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 55 times.
55 switch(k)
9144 {
9145 case KEY_F7:
9146 case KEY_F8:
9147 case KEY_F9:
9148 return KeyPress[k];
9149
9150 default:
9151
2/2
✓ Branch 0 taken 45 times.
✓ Branch 1 taken 10 times.
55 return KeyPress[k] && !disabledKeys[k];
9152 }
9153 55 }
9154
9155 // Is true for _every frame_ a key is held down.
9156 // But! it is possible that a script manually sets the value of KeyInput,
9157 // in which case it will be restored to the "true" value based on `key_current_frame`
9158 // on the next frame.
9159 bool zc_getkey(int32_t k, bool ignoreDisable)
9160 {
9161 if(ignoreDisable) return KeyInput[k];
9162 switch(k)
9163 {
9164 case KEY_F7:
9165 case KEY_F8:
9166 case KEY_F9:
9167 return KeyInput[k];
9168
9169 default:
9170 return KeyInput[k] && !disabledKeys[k];
9171 }
9172 }
9173
9174 // Reads (and then clears) the current frame key state directly.
9175 // Scripts can also modify `key_current_frame`.
9176 916 bool zc_readrawkey(int32_t k, bool ignoreDisable)
9177 {
9178
2/2
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 914 times.
916 if(zc_getrawkey(k, ignoreDisable))
9179 {
9180 2 _key[k]=key[k]=key_current_frame[k]=0;
9181 2 return true;
9182 }
9183 914 _key[k]=key[k]=key_current_frame[k]=0;
9184 914 return false;
9185 916 }
9186
9187 // Reads the current frame key state directly.
9188 // Scripts can also modify `key_current_frame`.
9189 124413661 bool zc_getrawkey(int32_t k, bool ignoreDisable)
9190 {
9191
2/2
✓ Branch 0 taken 106095208 times.
✓ Branch 1 taken 18318453 times.
124413661 if(ignoreDisable) return key_current_frame[k];
9192
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 18318453 times.
18318453 switch(k)
9193 {
9194 case KEY_F7:
9195 case KEY_F8:
9196 case KEY_F9:
9197 return key_current_frame[k];
9198
9199 default:
9200
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 18318453 times.
18318453 return key_current_frame[k] && !disabledKeys[k];
9201 }
9202 124413661 }
9203
9204 // Only used for a handful of keys, like tilde and Function keys.
9205 // This state is never read within the game.
9206 // It exists so that all keyboard input still functions during replay,
9207 // without inadvertently doing things like toggling throttling if the player
9208 // presses ~
9209 bool zc_get_system_key(int32_t k)
9210 {
9211 return key_system[k];
9212 }
9213
9214 // True for the _first_ frame of a key press.
9215 164865087 bool zc_read_system_key(int32_t k)
9216 {
9217 164865087 return key_system_press[k];
9218 }
9219
9220 2326429561 bool is_system_key(int32_t k)
9221 {
9222
2/2
✓ Branch 0 taken 2161564474 times.
✓ Branch 1 taken 164865087 times.
2326429561 switch (k)
9223 {
9224 case KEY_BACKQUOTE:
9225 case KEY_CLOSEBRACE:
9226 case KEY_END:
9227 case KEY_HOME:
9228 case KEY_OPENBRACE:
9229 case KEY_PGDN:
9230 case KEY_PGUP:
9231 case KEY_TAB:
9232 case KEY_TILDE:
9233 164865087 return true;
9234 }
9235 2161564474 return is_Fkey(k);
9236 2326429561 }
9237
9238 18318343 void update_system_keys()
9239 {
9240
2/2
✓ Branch 0 taken 2326429561 times.
✓ Branch 1 taken 18318343 times.
2344747904 for (int32_t q = 0; q < 127; ++q)
9241 {
9242
2/2
✓ Branch 0 taken 384685203 times.
✓ Branch 1 taken 1941744358 times.
2326429561 if (!is_system_key(q))
9243 1941744358 continue;
9244
9245 384685203 key_system[q] = key[q];
9246
1/2
✓ Branch 0 taken 384685203 times.
✗ Branch 1 not taken.
384685203 key_system_press[q] = key_system[q] && !key_system_previous[q];
9247 384685203 key_system_previous[q] = key_system[q];
9248 384685203 }
9249 18318343 }
9250
9251 19584855 void update_keys()
9252 {
9253
2/2
✓ Branch 0 taken 2487276585 times.
✓ Branch 1 taken 19584855 times.
2506861440 for (int32_t q = 0; q < 127; ++q)
9254 {
9255 // When replaying, replay.cpp takes care of updating `key_current_frame`.
9256
2/2
✓ Branch 0 taken 2487263885 times.
✓ Branch 1 taken 12700 times.
2487276585 if (!replay_is_replaying())
9257 12700 key_current_frame[q] = key[q];
9258
9259
2/2
✓ Branch 0 taken 2468183033 times.
✓ Branch 1 taken 19093552 times.
2487276585 KeyPress[q] = key_current_frame[q] && !key_previous_frame[q];
9260 2487276585 KeyInput[q] = key_current_frame[q];
9261 2487276585 key_previous_frame[q] = key_current_frame[q];
9262 2487276585 }
9263 19584855 }
9264
9265 bool zc_disablekey(int32_t k, bool val)
9266 {
9267 switch(k)
9268 {
9269 case KEY_F7:
9270 case KEY_F8:
9271 case KEY_F9:
9272 return false;
9273
9274 default:
9275 disabledKeys[k] = val;
9276 return true;
9277 }
9278 }
9279
9280 void zc_putpixel(int32_t layer, int32_t x, int32_t y, int32_t cset, int32_t color, int32_t timer)
9281 {
9282 timer=timer;
9283 particles.add(new particle(zfix(x), zfix(y), layer, cset, color));
9284 }
9285